Reputation: 73
I have a Xamarin.Forms app that needs to read data from a json file. I placed the file into the Android assets folder and selected the build action AndroidAssets
Then I try to load the file in MainActivity with Assets.Open(filename) and I get a FileNotFoundException. I deleted the Android and PCL bin folders and tried to build the project again but got the same result. Then I opened the .apk file in WinRar and when I go to the assets folder, the files that I added to the project are not there.
Does anyone have any idea what's the problem here?
Upvotes: 0
Views: 1861
Reputation: 73
The problem was with using the "-" character in resource file names. Changed it as suggested by York Shen and it started working as it was supposed to.
Upvotes: 2
Reputation: 1636
Did you set the files as embedded resources from the file properties?
If you not, right click on the file -> Properties -> set as Embedded Resources in Build Action
Upvotes: 2