Android Question File.Dir... error compiling expression

Gijsen

Member
Licensed User
Longtime User
When debugging my application, I get the value "error compiling expression" instead of the patch of for example File.DirInternalCache.

Android 4.2, B4A 5.20
 

Gijsen

Member
Licensed User
Longtime User
Code:
log(File.DirInternalCache)

(same for File.DirInteral, File.DirAssets, ...)


I tried to make a stacktrace and filter out the relevant lines.
Stack trace:

I/BufferQueue( 126): [nl.bazooh.maastricht/nl.bazooh.maastricht.main](this:0x444c1150,api:1) [queue] fps:0.41, dur:2424.60, max:2424.60, min:2424.60
I/BufferQueue( 126): [nl.bazooh.maastricht/nl.bazooh.maastricht.main](this:0x444c1150,api:1) [release] fps:0.41, dur:2432.64, max:2432.64, min:2432.64
I/B4A (23289): ����JFIF ...
...
I/B4A (23289): ~i:Message longer than Log limit (4000). Message was truncated.
I/BufferQueue( 126): [unnamed-126-264](this:0x422dca18,api:0) BufferQueue
I/BufferQueue( 126): [unnamed-126-264](this:0x422dca18,api:0) consumerConnect
I/BufferQueue( 126): [unnamed-126-264](this:0x422dca18,api:0) setConsumerName: unnamed-126-264
I/SurfaceTexture( 126): [unnamed-126-264](this:0x420d7008,api:0) SurfaceTexture
I/BufferQueue( 126): [unnamed-126-264](this:0x422dca18,api:0) setSynchronousMode: enabled=1
I/BufferQueue( 126): [unnamed-126-264](this:0x422dca18,api:0) setDefaultBufferSize: w=684, h=200
I/BufferQueue( 126): [nl.bazooh.maastricht/nl.bazooh.maastricht.main](this:0x422dca18,api:0) setConsumerName: nl.bazooh.maastricht/nl.bazooh.maastricht.main
V/WindowManager( 661): Changing focus from Window{412c8488 u0 nl.bazooh.maastricht/nl.bazooh.maastricht.main} to Window{412d70c8 u0 nl.bazooh.maastricht/nl.bazooh.maastricht.main}
I/SurfaceFlinger( 126): [SurfaceFlinger] fps:54.894066,dur:1001.93,max:34.51,min:15.59
I/B4A (23289): DownloadReady: ABS3.jpg
I/B4A (23289): ~de:main,912
I/B4A (23289): ~e:java.lang.RuntimeException: The Assets folder is a read-only folder
I/B4A (23289): ~e: at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:367)
I/B4A (23289): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
I/B4A (23289): ~e: at java.lang.reflect.Method.invoke(Method.java:525)
I/B4A (23289): ~e: at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:668)
I/B4A (23289): ~e: at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:334)
I/B4A (23289): ~e: at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:244)
I/B4A (23289): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
I/B4A (23289): ~e: at java.lang.reflect.Method.invoke(Method.java:525)
I/B4A (23289): ~e: at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
I/B4A (23289): ~e: at anywheresoftware.b4a.BA$3.run(BA.java:334)
I/B4A (23289): ~e: at android.os.Handler.handleCallback(Handler.java:800)
I/B4A (23289): ~e: at android.os.Handler.dispatchMessage(Handler.java:100)
I/B4A (23289): ~e: at android.os.Looper.loop(Looper.java:194)
I/B4A (23289): ~e: at android.app.ActivityThread.main(ActivityThread.java:5391)
I/B4A (23289): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
I/B4A (23289): ~e: at java.lang.reflect.Method.invoke(Method.java:525)
I/B4A (23289): ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
I/B4A (23289): ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
I/B4A (23289): ~e: at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
e:java.lang.RuntimeException: The Assets folder is a read-only folder
See Message. ASSETS is a read only folder. The path for assets and internalcache are different.

B4X:
    Log(File.DirInternalCache)
    Log(File.DirAssets)
results in

/data/data/b4a.example.ftpqueue/cache
AssetsDir

Dont try to save in assets as it is a READ ONLY folder.
 
Upvote 0

Gijsen

Member
Licensed User
Longtime User
Yes I've seen that in the log file.
But as posted with DirInternalCache and DirInternal I experience the same problem, a crash.

Do I need to add a permission in the manifest file so that the application is able to write on that folder.
Is there a way to catch the error in the code ?
 
Upvote 0

Gijsen

Member
Licensed User
Longtime User
This has been fixed by changing the manifest:

AddManifestText(<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>)
AddManifestText(<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>)

Thank you for your help.
 
Upvote 0
Top