Android Asset Loading
Solution 1:
Please check that Eclipse actually added your file to the project and that the file is named "bloop.wav". Go into the project folder using your file explorer/finder/etc
and see if it's there.
Also look into the .apk
that Eclipse creates (should be in the /bin
folder of you project).
Change the file extension to .zip
and have a look inside. If the wav is not there it might be that the /assets
folder is not added to the build path (in Eclipse go to File > Properties > Java Build Path > Source
(Tab) and maybe do a "Link Source" on the /assets
folder if it's not there)
Edit:
What is the output of the following code?
publicvoidonCreate(Bundle savedInstanceState) {
/.../try {
AssetManager assetManager = getAssets();
String[] list = assetManager.list("");
for (String s : list) {
System.out.println(s);
}
} catch (IOException e) {
Log.d("TAG", "Error was this ", e);
}
}
Solution 2:
Finally!! I've discovered the problem. Thank you very much @Hawkeye for giving your help, but it turns out the problem was with the way the files were placed in the assets folder. Normally I go to file > new > file > advanced (link from disk) in order to place files in my workspace, as I do with my other java programs. for SOME REASON this is not recognized for android applications and I had to go to the file on my computer, hit "copy", then go into my workspace and "paste" a physical copy of the file in the assets folder. For some reason, uploading the files in this manor causes the "assets" FOLDER to be created in the .apk file (if you do the link method, the file will be in the .apk, but the assets folder will not be there!). This solution is not posted anywhere else online and I had to discover this on my own. I hope this is able to help someone else.
Post a Comment for "Android Asset Loading"