Android Question Runtimepermission.GetSafeDirDefaultExternal ERROR after upgrade to 10.5

giggetto71

Active Member
Licensed User
Longtime User
HELP!
yesterday I upgraded to 10.5 from 10.2 now after the upgrade my app crashes upon executing the

B4X:
Dim rp As RuntimePermissions
DBPath = rp.GetSafeDirDefaultExternal("")

GetSafeDirDefaultExternal with the below logs. I did not change a bit in the code which was running just fine before the upgrade. I have also tried to add the external write permission to the manifest but no change

B4X:
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
    at anywheresoftware.b4a.objects.RuntimePermissions.GetSafeDirDefaultExternal(RuntimePermissions.java:120)
    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:193)
    at gigiosoft.MQTTAlert.starter.onCreate(starter.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4281)
    at android.app.ActivityThread.access$1500(ActivityThread.java:270)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2067)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7948)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Caused by: java.lang.ClassNotFoundException: androidx.core.content.ContextCompat
    ... 18 more
java.lang.RuntimeException: Unable to create service gigiosoft.MQTTAlert.starter: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4293)
    at android.app.ActivityThread.access$1500(ActivityThread.java:270)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2067)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7948)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at gigiosoft.MQTTAlert.starter.onCreate(starter.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4281)
    ... 8 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
    at anywheresoftware.b4a.objects.RuntimePermissions.GetSafeDirDefaultExternal(RuntimePermissions.java:120)
    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)
    ... 11 more
Caused by: java.lang.ClassNotFoundException: androidx.core.content.ContextCompat
    ... 18 more
 

giggetto71

Active Member
Licensed User
Longtime User
ok. I have downloaded and unzipped the Android SDK command tools and the required resources. I have also updated Java as I was using 8. now I am using 11 (B4J works ok with Java 11 after the update).
Apparently both Android zip have successfully installed I only got a strange error about 3 file adb

1609842964783.png



Unfortunately now it does not even build as it complains about a call to a JavaObject

B4X:
 Dim jo As JavaObject = nb
jo.RunMethod("setChannelId", Array("MyChannelId1"))

What did I miss?
thanks

1609841225473.png
 
Last edited:
Upvote 0

giggetto71

Active Member
Licensed User
Longtime User
ok. made more tests with an almost empty app and the issue seems to be related to the NotificationBuilder
here's the emtpy app that does not build.

1609845687633.png



B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
#AdditionalJar: com.android.support:support-v4

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Activity.LoadLayout("Layout")
     Dim nb As NotificationBuilder
     nb.Initialize
     Dim jo As JavaObject = nb    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub
 
Upvote 0
Top