Android Question RSCRop crashes when I select an image

Ted Fines

Member
Licensed User
Using B4A and the rscrop library. Connecting to device (Sony Experia running Android 8.0.0) using B4A-Bridge. App starts, and I can select an image. As soon as I tap the image the app crashes, and B4A log shows:
Error occurred on line: 73 (Main)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:517)
at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1343)
at b4a.rsexample.main._getimage_cropped(main.java:466)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at com.rootsoft.crop.RSCrop$1.ResultArrived(RSCrop.java:81)
at anywheresoftware.b4a.BA$4.run(BA.java:568)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:442)
at b4a.rsexample.main$ResumeMessage.run(main.java:306)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:251)
at android.app.ActivityThread.main(ActivityThread.java:6572)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
** Activity (main) Resume **

Line 73 of the code reads:
bmp = LoadBitmap(File.DirRootExternal,"tempImage.jpg")

I didn't see any other posts about this library throwing an exception like this with its default setup. Help! Thanks in advance.
 

josejad

Expert
Licensed User
Longtime User
Is the sample you are using updated to use Runtime Permissions?

Probably you don’t have permissions to read the image.

Ask for permission to read the path, or use an image in another path.

Property_501.png
DirRootExternal As String [read only]

Returns the root folder of the external storage media.
This folder requires the WRITE_EXTERNAL_STORAGE permission. Only use it if you really need to access this folder.
You should probably use File.DirInternal or RuntimePermissions.GetSafeDirDefaultExternal instead.
 
Upvote 0
Top