Bug? Resources not updated when app recompiled

Computersmith64

Well-Known Member
Licensed User
Longtime User
There appears to be an issue in B4A where resources are not updated on the device when they are changed & the app is recompiled.

In an app I'm currently working on, I had a bunch of .png files whose names started with "icon_". After running the app on multiple devices for several weeks, today I changed the file names so they start with "ic_". After doing this, I removed all the old files (starting with "icon_") using the IDE file manager, then added the new files (starting with "ic_").

When I compiled the app & ran it on a device, it crashed with the following error:
*** Service (starter) Create ***
** Service (starter) Start **
*** Service (firebasemessaging) Create ***
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (firebasemessaging) Start **
java.lang.RuntimeException: java.io.FileNotFoundException: icon_person_black_24dp.png
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1679)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.io.FileNotFoundException: icon_person_black_24dp.png
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:313)
at android.content.res.AssetManager.open(AssetManager.java:287)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:202)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:515)
at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1315)
at com.airlinemates.followme.apputils._vvvvvv2(apputils.java:249)
at com.airlinemates.followme.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv2(main.java:2086)
at com.airlinemates.followme.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv3(main.java:1357)
at com.airlinemates.followme.main$ResumableSub_Activity_Create.resume(main.java:647)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1677)
... 7 more

The file being reported as not found ("icon_person_black_24dp.png") was one of the files I changed to start with "ic_". The only way I could get the app to run was to uninstall it from the device, then recompile & install it. I had to do this on all my devices that had previously run the app.

Is there a way to force B4A to update the resources when the app is recompiled?

- Colin.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see that you are running it in release mode. In release mode all the files are packaged inside the APK. All asset files will always be updated.
(In debug mode the process is more complicated but it is not relevant here)

You can open the APK with 7zip and see which files are there.

Note that you can click on Sync Folder in the IDE to update the Files list with the Files folder content.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
I see that you are running it in release mode. In release mode all the files are packaged inside the APK. All asset files will always be updated.
(In debug mode the process is more complicated but it is not relevant here)

You can open the APK with 7zip and see which files are there.

Note that you can click on Sync Folder in the IDE to update the Files list with the Files folder content.

Sorry Erel, but I'm not understanding what you're saying here. I just clicked on the sync button, recompiled (in release mode) & the app crashed. I checked the .apk & the correct resources are in there. I recompiled in debug & it ran fine, so I recompiled in release mode & it crashed again with the same error.

So it seems like the assets are being packaged correctly, but there's something in the compiled code that's not getting updated & it's still pointing to the old assets.

- Colin.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Ahhhh - I found the problem. The old filename was being picked up from the user options file. D'oh!

There is one weird thing about this that perhaps you can explain: In release mode, the LoadBitmap causes the crash because the file it's trying to load doesn't exist - however in debug mode it doesn't. It doesn't give any indication that there's an issue - in fact I can step through the code & watch the LoadBitmap return from trying to load the non-existent file without any problem. Shouldn't it crash like it does in release mode?

- Colin.
 
  • Like
Reactions: eps
Top