Android Question Strange Problem

colboy

Member
Licensed User
Longtime User
I'm developing on two devices and have come across a weird problem. On my my Galaxy Tab A with Android 7, when I run my program, everything appears to run fine, with no errors in the log, but when I run on my ZKC with Andoird 5, I get errors and it doesn't run. Here's the log.

Copying updated assets files (4)
java.lang.RuntimeException: Unable to create service com.colinmeeks.abcclient.starter: java.lang.RuntimeException: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.colinmeeks.abcclient/files/virtual_assets/compuplusnew-300.jpg: open failed: ENOENT (No such file or directory)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2771)
at android.app.ActivityThread.access$1800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.colinmeeks.abcclient/files/virtual_assets/compuplusnew-300.jpg: open failed: ENOENT (No such file or directory)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:169)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at com.colinmeeks.abcclient.starter.onCreate(starter.java:34)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761)
... 9 more
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.colinmeeks.abcclient/files/virtual_assets/compuplusnew-300.jpg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:448)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:156)
... 13 more
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 16 more

It was working fine on ZKC device. I've verified the image is where it's meant to be. Strange it works find on one and not the other.

Colin
 

walterf25

Expert
Licensed User
Longtime User
I'm developing on two devices and have come across a weird problem. On my my Galaxy Tab A with Android 7, when I run my program, everything appears to run fine, with no errors in the log, but when I run on my ZKC with Andoird 5, I get errors and it doesn't run. Here's the log.



It was working fine on ZKC device. I've verified the image is where it's meant to be. Strange it works find on one and not the other.

Colin
Seems like you're missing a file complusnew-300.jpg

Walter
 
Upvote 0

colboy

Member
Licensed User
Longtime User
Yes, but it's there in the files section for the form. And as I said, it's fine on one device, but not the other.
In addition, if I make a release and run that, it works fine on the device, and the suppose image that can't be found is showing fine. If I run in debug, I get the error and cannot proceed.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Try replacing the hyphen in the file name with an underscore.

- Colin.
 
Upvote 0

colboy

Member
Licensed User
Longtime User
Try replacing the hyphen in the file name with an underscore.

- Colin.
I tried removing it altogether. The image is used on multiple forms, so to help diagnose, I removed it from all forms and created a new file for each form:
pic1.jpg
pic2.jpg
pic3.jpg

I then added it to each form and then pointed the image to the correct version and now a variation of the problem. The error log is now:

Copying updated assets files (6)
java.lang.RuntimeException: Unable to create service com.colinmeeks.abcclient.starter: java.lang.RuntimeException: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.colinmeeks.abcclient/files/virtual_assets/login.bal: open failed: ENOENT (No such file or directory)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2771)
at android.app.ActivityThread.access$1800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.colinmeeks.abcclient/files/virtual_assets/login.bal: open failed: ENOENT (No such file or directory)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:169)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at com.colinmeeks.abcclient.starter.onCreate(starter.java:34)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761)
... 9 more
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.colinmeeks.abcclient/files/virtual_assets/login.bal: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:448)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:156)
... 13 more
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 16 more

Again if I run in release mode, everything works fine.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Can you post the line of code that is referring to login.bal? Are you inadvertently trying to load a layout file instead of an image?

- Colin.
 
Upvote 0

colboy

Member
Licensed User
Longtime User
Can you post the line of code that is referring to login.bal? Are you inadvertently trying to load a layout file instead of an image?

- Colin.
It's the initial layout being opened
B4X:
Activity.LoadLayout("login")

It's frustrating as it's running in Release and also runs in debug on my Galaxy Tab A
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Ohhhhh, I see what the problem is, you are trying to read a file from the internal storage, have you added the necessary permissions for that?

I suggest you do a search for RunTime Permissions.

Cheers,
Walter
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Ohhhhh, I see what the problem is, you are trying to read a file from the internal storage, have you added the necessary permissions for that?

I suggest you do a search for RunTime Permissions.

Cheers,
Walter
I don't think so because he reported that it's happening on the Android 5 device & not on the Android 7 one. I think runtime permissions only started in Android 6. Regardless, you don't need any dangerous permissions to access files in the assets directory.

Also, he reports that it runs fine in release mode, but not debug - so I think it's more likely the debug permissions bug in the internal library that Erel fixed in the link I provided.

I could be wrong though...

- Colin.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I don't think so because he reported that it's happening on the Android 5 device & not on the Android 7 one. I think runtime permissions only started in Android 6. Regardless, you don't need any dangerous permissions to access files in the assets directory.

Also, he reports that it runs fine in release mode, but not debug - so I think it's more likely the debug permissions bug in the internal library that Erel fixed in the link I provided.

I could be wrong though...

- Colin.
If you pay careful attention to the logs he posted, the file is referring to is in the /Storage/Emulated/0 directory, in that case yes he would need permissions but as you mentioned only if he is running on Android 7 and above.

/storage/emulated/0/Android/data/com.colinmeeks.abcclient/files/virtual_assets/login.bal: open failed: ENOENT (No such file or directory)
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
If you pay careful attention to the logs he posted, the file is referring to is in the /Storage/Emulated/0 directory, in that case yes he would need permissions but as you mentioned only if he is running on Android 7 and above.

Yeah, but it runs fine in release mode - which would indicate that it's not a permissions issue & it's crashing in debug mode on an Android 5 device - which doesn't require runtime permissions. Also, look at the last part of the path (virtual_assets).

If you look at the link I provided in one of my previous posts, you'll see that the bug fix for the B4A v8.5 internal library resolves pretty much exactly the issue he is reporting.

- Colin.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Yeah, but it runs fine in release mode - which would indicate that it's not a permissions issue & it's crashing in debug mode on an Android 5 device - which doesn't require runtime permissions. Also, look at the last part of the path (virtual_assets).

If you look at the link I provided in one of my previous posts, you'll see that the bug fix for the B4A v8.5 internal library resolves pretty much exactly the issue he is reporting.

- Colin.
good to know, although the real issue was still missing permissions as the post you are pointing to refers to, the updated Debug.jar file fixes an issue with missing permissions :D

Walter
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
good to know, although the real issue was still missing permissions as the post you are pointing to refers to, the updated Debug.jar file fixes an issue with missing permissions :D

Walter

*sigh*
 
Upvote 0
Top