Android Question java.io.FileNotFoundException: images when compiling with RELEASE. DEBUG works fine

Garrett

New Member
Licensed User
Hello,

New to using B4A and have created my first app. I'm using B4A-Bridge on my Android device and when I compile/run in Debug, the app works fine.

However when I change to Release and do the same, I get an error that my app has stopped (on the device) and this in the logger:

Logger connected to: ZTE ZTE A2017U
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Readable:true
Writeable:true
main_activity_create (java line: 403)
java.io.FileNotFoundException: images
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:353)
at android.content.res.AssetManager.open(AssetManager.java:327)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:205)
at anywheresoftware.b4a.objects.streams.File.Copy(File.java:338)
at b4a.TestApp.main._activity_create(main.java:403)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at b4a.TestApp.main.afterFirstLayout(main.java:104)
at b4a.TestApp.main.access$000(main.java:17)
at b4a.TestApp.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6236)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)

I've tried a few things -- reinstall Android SDK and re-download with the SDK manager, checked JDK is current (jdk1.8.0_161), etc.

Any suggestions are appreciated, and my apologies in advance if I'm missed something really simple.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
I had a similar issue with one image file in one of my projects & in the end I had to work around it by copying the file from the DirAssets to DirInternal. I can't remember the details or what else I tried though sorry.

- Colin.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Try adding this line to your main module...
B4X:
#DebuggerForceStandardAssets: True

EDITED: Actually you said debug works fine, so the above line will not help you.

This might sound strange, but have you tried uninstalling and reinstalling the actually app on the device manually then running Release again?
 
Last edited:
Upvote 0

Garrett

New Member
Licensed User
Hi all, thanks for the suggestions. I'll address each of them best I can -- unfortunately the error has ceased so I'm not sure what was causing it.

First, I'm not using any images in the app -- it's a very simple audio player for a specific purpose, so just a few buttons and listviews. I think the "image" it refers to must be something built-in to android or java.

Second, I did try remove and re-install a few times without success.

Third, it doesn't even seem to start the app -- the crash is on main_activity_create when opening the first activity.

As far as what did happen between it not working and now:

1. Connected a different device on B4A Bridge (Samsung tablet) and deployed to that. No issues either with Debug or Release.

2. So I thought maybe it's something with the phone I was originally deploying to (ZTE Axon 7 running RR custom rom, Nougat based) -- removed and re-installed to the phone, and the error seems to be gone.

3. Since, cannot make the error recur. I'll try to do so to narrow it down, but it was happening consistently until I deployed to a new device and then came back to the original one. Is it possible that makes some difference in the build?

Thanks again for all the suggestions, and I'll update further if I can recreate and/or narrow down the problem in case anybody else comes across it.

G
 
Upvote 0
Top