Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 485
AJJ Avatar asked May 17 '16 15:05

AJJ


People also ask

How do I view an asset file?

To view asset files in Files home, select Libraries and then select Asset Library . To view and edit asset files in Setup, enter Asset Files in the Quick Find box, then select Asset Files. Click the name of a resource to view its details.

What does asset file mean?

An Asset Definition file is an optional XML file that you can use to import assets into SiteProtector. The Asset Definition file provides a complete list of information about an asset, including information that you specify in the New Asset window, such as Criticality, Function, and OS version.

How do you create a file from assets in flutter?

Create an assets folder in your project's root folder. In Android Studio you can right click the Project outline and go to New > Directory. You can create another subfolder for text files in assets if you like. But if you do, you have to include the relative path in pubspec.


1 Answers

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.

like image 157
AJJ Avatar answered Oct 31 '22 11:10

AJJ