Android Question Error java.lang.ClassNotFoundException in B4A Versiom 12.8 but not in 12.2

Rubens Jr.

Member
Licensed User
Hi

This test code works in verion 12.2 of B4A, but when I upgrade to version 12.8 this error occurs.

Select Folder in External SD:
Private Sub bt_sync_Click
    
    Dim mp3_Storage As ExternalStorage
    
    mp3_Storage.Initialize (Me, "mp3_storage")
    mp3_Storage.SelectDir (False)
    Wait For mp3_Storage_ExternalFolderAvailable
    If mp3_Storage.IsInitialized = False Or mp3_Storage.root.Length <= 0 Then
        Log ("Not selected")
        Return
    End If

    Log ("ok")
        
End Sub

The log :


Log:
*** mp3_config: B4XPage_Appear [mp3]
** Activity (main) Pause event (activity is not paused). **
*** mp3_config: B4XPage_Disappear [mp3_config]
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
content://com.android.externalstorage.documents/tree/D8EE-992F%3AMP3
externalstorage_vvvvvvvvvvvvvvvvvvvv1 (java line: 200)
java.lang.ClassNotFoundException: androidx$documentfile$provider$DocumentFile
    at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:289)
    at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:75)
    at scm.painel.externalstorage._vvvvvvvvvvvvvvvvvvvv1(externalstorage.java:200)
    at scm.painel.externalstorage._vvvvvvvvvvvvvvvvvvvv6(externalstorage.java:362)
    at scm.painel.externalstorage._ion_event(externalstorage.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4j.object.JavaObject$1.invoke(JavaObject.java:238)
    at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
    at $Proxy0.ResultArrived(Unknown Source)
    at anywheresoftware.b4a.BA$4.run(BA.java:593)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:467)
    at scm.painel.main$ResumeMessage.run(main.java:313)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    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:951)
java.lang.ClassNotFoundException: androidx$documentfile$provider$DocumentFile

For now I will continue to use version 12.2 .... but waht can I do to avoid this error ?

Thanks

Rubens Jr.
 

Rubens Jr.

Member
Licensed User
Did you installed a NEW SDK together with the update to 12.5+?

I guess you are using an "old SDK"?
Thanks for the reply, but ...
I renamed c:\java to c:\java_old and renamed c:\Android to c:\Android_old
Download files according the site :
Java version:
C:\Java\bin>java --version
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7)
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

C:\Java\bin>

Android:
30/10/2022  05:47    <DIR>          .
30/10/2022  05:47    <DIR>          ..
30/10/2022  05:47         7.195.875 android-stubs-src.jar
30/10/2022  05:47        27.138.945 android.jar
30/10/2022  05:47             4.584 build.prop
30/10/2022  05:47         1.367.407 core-for-system-modules.jar
30/10/2022  05:47    <DIR>          data
30/10/2022  05:47            51.339 framework.aidl
30/10/2022  05:47    <DIR>          optional
30/10/2022  05:47            18.461 package.xml
30/10/2022  05:47               209 sdk.properties
30/10/2022  05:47    <DIR>          skins
30/10/2022  05:47               256 source.properties
30/10/2022  05:47    <DIR>          templates
30/10/2022  05:47            10.547 uiautomator.jar
               9 arquivo(s)     35.787.623 bytes
               6 pasta(s)   157.110.108.160 bytes disponíveis

C:\Android\platforms\android-33>

I Closed B4A, open it again, recompile and the error continues
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Thanks for the reply, but ...
I was talking about the SDK. NOT JAVA.
I can´t see how your answer will help here?

I suggest to
DELETE the SDK
Installl it fresh based on the installationinstructions.
Configure the IDE to use the new SDK.

Try again.

Please answer when you did installed the SDK the last time?
Today? A year ago? Longer?
 
Upvote 0

Rubens Jr.

Member
Licensed User
Thanks again.
I Followed all instructions on installation : Download the Java as step 1 and run java --version to confirm this.
Then I Downloaded the Android SDK Command line tools and required resources. as step 2, and unzip it on C:\Android as sugested.
The SDK Android\plataforms\android-33 I Select in B4A / Paths ...

What I Miss ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Rubens Jr.

Member
Licensed User
Hi

First off all : Thanks to reply me and spent your time with this question .
I think a found a solution.
After a lot of search here in forum I found this :
add this line im Main Module before the Sub Process_Globals :

#AdditionalJar: androidx.legacy:legacy-support-core-utils

With this line now I can use version 12.8 with new SDK and new Java and no erros

Thanks Again.

Rubens Jr.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…