Godot Version
4.2.0
Question
I am trying to use Kotlin’s coroutine in my android library for Godot. Below is the complete error message
Process: com.example.mygodotapp, PID: 21586
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/SupervisorKt;
at com.example.androidlocation.LocationService.<init>(LocationService.kt:21)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4922)
at android.app.ActivityThread.access$1800(ActivityThread.java:310)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2300)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlinx.coroutines.SupervisorKt" on path: DexPathList[[zip file "/data/app/~~ODYQy-wm45_J8E3bkTjOVA==/com.example.mygodotapp-TDcRajdFrZrn0B_hub7hLA==/base.apk"],nativeLibraryDirectories=[/data/app/~~ODYQy-wm45_J8E3bkTjOVA==/com.example.mygodotapp-TDcRajdFrZrn0B_hub7hLA==/lib/arm, /data/app/~~ODYQy-wm45_J8E3bkTjOVA==/com.example.mygodotapp-TDcRajdFrZrn0B_hub7hLA==/base.apk!/lib/armeabi-v7a, /system/lib, /system/system_ext/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.example.androidlocation.LocationService.<init>(LocationService.kt:21)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4922)
at android.app.ActivityThread.access$1800(ActivityThread.java:310)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2300)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Here is the my android library repo and here is the Godot repo
My code crashes when i try to use below code in my android library
private val serviceScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
I am using kotlin 1.9.10
which contain coroutines internally and i have not added any coroutines dependencies externally