Search code examples
javaandroidfileandroid-studioassets

File not found when loading from assets?


I included several pre-made .png files in my assets folder, but only some of them are getting through without error:

AssetManager assetManager = context.getAssets();
Inputstream in = assetManager.open(assetName);

where assetName is a String containing something like "myPic.png".

It seems to work for some of the files, but for others it throws java.io.FileNotFoundException: myPic.png even though I see it right there in the Assets folder alongside plenty of other files that seem to be making the cut.


Solution

  • Apparently closing / reopening the project in Android Studio was enough to get it to work correctly. No idea why it wasn't noticing all the assets in the first place, but now it does after restarting.