Android Question How to use AdditionalJar in a service ?

fs007

Member
Adding the "#AdditionalJar:" tag to a service or modul code results in an error message in the IDE.
But "#AdditionalJar:" only in Main throws an error at runtime:

java.lang.RuntimeException: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Duration;
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:188)
at anywheresoftware.b4a.BA$1.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Duration;
at com.google.auth.oauth2.OAuth2Credentials.<clinit>(OAuth2Credentials.java:70)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at java.lang.Class.forName(Class.java:285)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:274)
at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:75)
at my.gsensor4.firebasemessaging._gettokenvalue(firebasemessaging.java:299)
at my.gsensor4.firebasemessaging$ResumableSub_senden2.resume(firebasemessaging.java:435)
at my.gsensor4.firebasemessaging._senden2(firebasemessaging.java:410)
at my.gsensor4.firebasemessaging._senden(firebasemessaging.java:276)
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:157)
... 8 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.time.Duration" on path: DexPathList[[zip file "/data/app/my.gsensor4-1/base.apk"],nativeLibraryDirectories=[/data/app/my.gsensor4-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 24 more
 

fs007

Member
..... the error has nothing to do with the place you put #AdditionalJar.
Really ???
Why does IDE show an error ("Attribute not supported:additonaljar") to this code:

Service module::
#Region  Service Attributes
    #StartAtBoot: False
    
#End Region

#AdditionalJar: google-auth-library-credentials-1.18.0

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

End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub

Sub Service_Destroy

End Sub

Erel said:
you are trying to use a Jar not compatible with Android.
where to get a compatible version ?
 
Upvote 0
Top