Skip to content Skip to sidebar Skip to footer

Xamarin Android Assets.open Throws Filenotfound Exception

It seems to be very easy, but don't know why I can't use Assets.open method without getting FileNotFound exception. I followed an example in xamrain.com http://docs.xamarin.com/gu

Solution 1:

Firstly, without seeing your code, it's impossible to see any mistakes you may have missed. It's easy to miss a filename issue, or other problem that may not be so obvious.

Speculatively though, I will try to give you some pointers.

The 'Copy to Output Directory' setting is not important for Android resources. The build action of AndroidAsset will ensure that the file is included in the app package, allowing you to load it using Assets.Open().

To confirm this, have a look for the compiled .apk file in the bin/debug or bin/release folder. The .apk file is simply an archive, so you can open it up with with winrar, or 7-zip, or rename it to .zip and windows will open it.

If the file is in the assets folder, then there is probably a problem with your code. You should post it in your question. If the file isn't there, try cleaning your project, or deleting the bin folder to force a fresh build and re-package.

Solution 2:

Check properties of the file. I had to set "Build Action" to AndroidAsset and after this it works fine.

Solution 3:

I got this problem before, and I finally found a image file in my directory assets/ was named by Chinese characters so the images in the assets are not loaded in correct way.

I guess you should check out the filenames if it was badly coded.

Solution 4:

You should try name files only in lowercase. Sometimes android convert names to lower even file contains uppercase.

Post a Comment for "Xamarin Android Assets.open Throws Filenotfound Exception"