Popeye
Popeye

Reputation: 263

Unable to create service : Java.lang.ClassNotFoundException in Android

I have an Android application which uses a SDK library to send data. I packed the SDK library as .aar file and added the dependency in the App.

I'm trying to replicate the following exception in my local that my users are experiencing.

enter code here](Process: com.GA.injector, PID: 13175
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.java.android.GAService: java.lang.ClassNotFoundException: Didn't find class "com.java.android.GAService" on path: DexPathList[[zip file "/system/priv-app/Injector/Injector.apk"],nativeLibraryDirectories=[/system/priv-app/Injector/lib/x86_64, /system/lib64, /system/product/lib64, /system/lib64, /system/product/lib64]]
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:4198)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.app.ActivityThread.access$1500(ActivityThread.java:237)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7664)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.java.android.GAService" on path: DexPathList[[zip file "/system/priv-app/Injector/Injector.apk"],nativeLibraryDirectories=[/system/priv-app/Injector/lib/x86_64, /system/lib64, /system/product/lib64, /system/lib64, /system/product/lib64]]
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
04-23 22:49:14.900 2010093 13175 13175 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:4177))

GAService is a service added in the manifest file of the SDK library. This issue seems to be intermittent in the user side.

In what scenario, does this exception occur? I'm having trouble reproducing the issue.

Upvotes: 0

Views: 508

Answers (1)

Ariczek
Ariczek

Reputation: 308

What exactly is this com.java.android.GAService? Some custom native library provided as .so file?

From my experience, there is different behaviour on different versions of Android. On some versions, native libs are being loaded automatically, on some you need to load them explicitly.

Try to add something similar to your code, before using this GAService - assuming the file is libgaservice.so:

System.loadLibrary("gaservice");

Upvotes: 0

Related Questions