Defi
May 14, 2016, 10:06pm
1
I want to export an android library to Unity, but that Android gives the following error:
05-1412:58:10.60118408-18408/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.joostverbraeken.weargame, PID:18408
java.lang.RuntimeException:Unable to instantiate activity ComponentInfo{com.joostverbraeken.weargame/com.joostverbraeken.weargame.MainActivity}: java.lang.ClassNotFoundException:smile:idnât find class âcom.joostverbraeken.weargame.MainActivityâ on path: DexPathList[[zip file â/data/app/com.joostverbraeken.weargame-1/base.apkâ],nativeLibraryDirectories=[/data/app/com.joostverbraeken.weargame-1/lib/arm, /data/app/com.joostverbraeken.weargame-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5436)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
Caused by: java.lang.ClassNotFoundException: Didnât find class"com.joostverbraeken.weargame.MainActivity" on path:smile:exPathList[[zip file â/data/app/com.joostverbraeken.weargame-1/base.apkâ],nativeLibraryDirectories=[/data/app/com.joostverbraeken.weargame-1/lib/arm,/data/app/com.joostverbraeken.weargame-1/base.apk!/lib/armeabi-v7a,/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)
at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2322)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5436)
at java.lang.reflect.Method.invoke(NativeMethod)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)Suppressed: java.lang.NoClassDefFoundError: com.joostverbraeken.weargame.MainActivity
at dalvik.system.DexFile.defineClassNative(NativeMethod)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:338)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)âŚ13 more
Suppressed: java.lang.ClassNotFoundException: com.joostverbraeken.weargame.MainActivity
at java.lang.Class.classForName(NativeMethod)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)âŚ12 more
Causedby: java.lang.NoClassDefFoundError:Classnot found using the boot class loader;no stack trace available
I copied all code that could be relevant below, probably you can skip half of it
My AndroidManifest (I copied the one from my library into Unity) is as follows:
The dependencies are fairly straightforward and are declared in Gradle:
dependencies {
compile fileTree(dir:âlibsâ, include:[â*.jarâ], exclude:[âclasses.jarâ])
provided files(âlibs/classes.jarâ)
wearApp project(â:wearâ)
compile âcom.google.android.gms:play-services:8.4.0â
compile âcom.android.support:support-v4:23.4.0â}
On a forum I read Unity needed to have the dependencies copied into Assets/Plugins/Android, although Iâm using an aar instead of a jar. So I copied support-v4-23.3.0-sources.jar into Assets/Plugins/Android as well, but play-services-8.4.0.jar not because itâs not included in the Android system files. play-services-8.4.0.aar is included, but if I copy that to Unity I get the following error:
Does anybody have an idea how to solve the ClassNotFoundException?
Are you sure that the activity class com.joostverbraeken.weargame.MainActivity exists inside your Unity project, compiled into a .jar file, .aar file or an Android library project ?