使用 netbeans 获取资产 android 错误,修复吗?
我正在以下网站上查看修复程序。该网站告诉您如何解决 netbeans 中的无资产问题。
http://blog.yetisoftware.com/2009/04/02/android-netbeans-and-the-assets-directory/
问题是我没有名为“的文件目录中的 build-impl.xml"。
事实上,对于我的 Android 项目我没有“nbproject 文件夹。”
希望有人能告诉我应该做什么来解决这个问题,因为我无法获取任何资产。
我的问题是我缺少一个文件夹和一个文件!我该怎么办?
__ 新信息 __
错误:
02-02 13:34:41.763: I/jdwp(282): Ignoring second debugger -- accepting and dropping
02-02 13:34:42.412: D/dalvikvm(282): GC_EXTERNAL_ALLOC freed 766 objects / 54840 bytes in 151ms
02-02 13:34:42.422: I/Problem(282): GOT HERE!
02-02 13:34:42.662: W/dalvikvm(282): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
02-02 13:34:42.662: E/AndroidRuntime(282): FATAL EXCEPTION: Thread-8
02-02 13:34:42.662: E/AndroidRuntime(282): java.lang.NullPointerException
02-02 13:34:42.662: E/AndroidRuntime(282): at tiny.bomber.LoadingScreen.update(LoadingScreen.java:33)
02-02 13:34:42.662: E/AndroidRuntime(282): at framework.impl.FastRenderView.run(FastRenderView.java:35)
02-02 13:34:42.662: E/AndroidRuntime(282): at java.lang.Thread.run(Thread.java:1096)
02-02 13:34:46.142: I/Process(282): Sending signal. PID: 282 SIG: 9
错误行:
assets.plane = assets.fetchImage("assets.png");
Assets.fetchImage 代码:
public Bitmap fetchImage(String location) {
try {
InputStream is = assetManager.open(location);
Bitmap image = BitmapFactory.decodeStream(is);
return image;
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
我对所有内容进行了更新,但它仍然没有打开。这是我的文件夹所在位置和我所做的事情的图片。
在“C:\Users\USER_NAME\Documents\NetBeansProjects\APP_NAME\project.properties”中,我添加了三个线。
- asset.dir=assets
- asset.available=true
- asset.dir=assets
然后我找不到build-impl.xml,发现我什至不在正确的文件夹中。我什至不在“nbproject”文件夹中。在该目录中,我什至没有它,而我的其他常规 java 项目却有。我的安卓机没有。因此,在更新后,我创建了一个新项目,但仍然没有该文件夹或我需要的文件。
我现在该怎么办?
__最新信息__
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
public class Assets {
AssetManager assetManager;
public Bitmap background;
public Bitmap plane;
public Assets(AssetManager assets) {
this.assetManager = assets;
}
public Bitmap fetchImage(String location) {
try {
InputStream is = assetManager.open(location);
Bitmap image = BitmapFactory.decodeStream(is);
return image;
} catch(Exception e) {
Log.e("fetchImage(Location)", e.getMessage());
}
return null;
}
public Bitmap fetchImage(String location, Boolean assetManager) {
if(assetManager) {
return fetchImage(location);
} else {
try {
InputStream is = new BufferedInputStream(new FileInputStream("/assets/" + location));
Bitmap image = BitmapFactory.decodeStream(is);
return image;
} catch(Exception e) {
Log.e("fetchImage(Location, Boolean)", e.getMessage());
}
return null;
}
}
}
在我刚刚在上面发布的这个类中,我添加了“fetchImage(Location, noAssetManager);”看看我是否可以在没有资产管理器的情况下获得图像。我想知道这可能吗?
我一直在尝试向该位置添加不同的东西,但没有任何效果。我尝试了以下方法。
- “assets/”+位置
- “/assets/”+位置
- “./assets/”+位置
有什么想法吗?只要我能找到一种方法或另一种方法就可以了!谢谢!
I was looking at a fix on the following website. This websites tells you how to fix the no assets problem in netbeans.
http://blog.yetisoftware.com/2009/04/02/android-netbeans-and-the-assets-directory/
Problem is that I don't have a file called "build-impl.xml" within the directory.
In fact for my android project I don't have a 'nbproject folder.
Hopefully someone can tell me what I should do to fix this problem since I can't get any of my assets.
My problem is that I missing a folder and a file! What should I do about this?
__ NEW INFORMATION __
Errors:
02-02 13:34:41.763: I/jdwp(282): Ignoring second debugger -- accepting and dropping
02-02 13:34:42.412: D/dalvikvm(282): GC_EXTERNAL_ALLOC freed 766 objects / 54840 bytes in 151ms
02-02 13:34:42.422: I/Problem(282): GOT HERE!
02-02 13:34:42.662: W/dalvikvm(282): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
02-02 13:34:42.662: E/AndroidRuntime(282): FATAL EXCEPTION: Thread-8
02-02 13:34:42.662: E/AndroidRuntime(282): java.lang.NullPointerException
02-02 13:34:42.662: E/AndroidRuntime(282): at tiny.bomber.LoadingScreen.update(LoadingScreen.java:33)
02-02 13:34:42.662: E/AndroidRuntime(282): at framework.impl.FastRenderView.run(FastRenderView.java:35)
02-02 13:34:42.662: E/AndroidRuntime(282): at java.lang.Thread.run(Thread.java:1096)
02-02 13:34:46.142: I/Process(282): Sending signal. PID: 282 SIG: 9
Error line:
assets.plane = assets.fetchImage("assets.png");
Assets.fetchImage code:
public Bitmap fetchImage(String location) {
try {
InputStream is = assetManager.open(location);
Bitmap image = BitmapFactory.decodeStream(is);
return image;
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
I did an update on everything and it is still not open. Here is a picture of where my folder is and what I did.
In "C:\Users\USER_NAME\Documents\NetBeansProjects\APP_NAME\project.properties" I added three lines.
- assets.dir=assets
- assets.available=true
- asset.dir=assets
Then I couldn't find build-impl.xml and found that I wasn't even in the right folder. I wasn't even in 'nbproject' folder. In that directory I don't even have it while my other regular java projects do. My android ones did not. So after my update I made a new project and still didn't have that folder or the file I needed.
What should I do now?
__ NEWEST INFORMATION__
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
public class Assets {
AssetManager assetManager;
public Bitmap background;
public Bitmap plane;
public Assets(AssetManager assets) {
this.assetManager = assets;
}
public Bitmap fetchImage(String location) {
try {
InputStream is = assetManager.open(location);
Bitmap image = BitmapFactory.decodeStream(is);
return image;
} catch(Exception e) {
Log.e("fetchImage(Location)", e.getMessage());
}
return null;
}
public Bitmap fetchImage(String location, Boolean assetManager) {
if(assetManager) {
return fetchImage(location);
} else {
try {
InputStream is = new BufferedInputStream(new FileInputStream("/assets/" + location));
Bitmap image = BitmapFactory.decodeStream(is);
return image;
} catch(Exception e) {
Log.e("fetchImage(Location, Boolean)", e.getMessage());
}
return null;
}
}
}
In this class that I just posted above I added the 'fetchImage(Location, noAssetManager);' to see if I could get the image without the asset manager. What I would like to know is this possible?
I keep trying different things to add on to the location, but nothing was working. I tried the following.
- "assets/" + location
- "/assets/" + location
- "./assets/" + location
Any ideas? Long as I can get one method or the other to work ill be fine!!! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的链接描述了旧版本的 nbandroid 插件。如果您使用当前的资源(假设您根据您的评论进行操作),那么您应该能够在项目中使用资源。基本上 http://developer.android.com/guide/developing 中描述的任何内容/projects/projects-cmdline.html 预计可以正常工作,因为该插件现在委托构建来构建由 SDK 工具创建和更新的脚本。
这意味着只需在磁盘上创建文件夹并将文件放在那里,它就会正确构建。如果没有,请告诉我们更多详细信息 - http://www.nbandroid.org/p/contacts .html
-Radim
Your link describes an old version of nbandroid plugin. If you use the current one (supposedly you do according to your comments) then you should be able to use assets in your project. Basically anything described in http://developer.android.com/guide/developing/projects/projects-cmdline.html is expected to work because the plugin delegates building to build scripts created and updated by SDK tools now.
It means just create the folder on the disk and put your file there and it will be built correctly. If it does not then tell us more details - http://www.nbandroid.org/p/contacts.html
-Radim