java.lang.NoClassDefFoundError: Failed resolution of: Lcom/touguyun/kotlin/KotlinTest;


#1

AndroidStudio3.0 Canary3
kotlin_version = ‘1.1.2-5’
'com.android.tools.build:gradle:2.2.3’
java.lang.NoClassDefFo undError: Failed resolution of: Lcom/touguyun/kotlin/KotlinTest;
at com.touguyun.activity.MainActivity.onToolsClick(MainActivity.java:119)
at com.touguyun.view.MainBottomToolsView$1.onClick(MainBottomToolsView.java:154)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21177)
at android.os.Handler.handleCallback(Handler.java:742)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:740)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)
Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.touguyun.kotlin.KotlinTest” on path: DexPathList[[zip file “/data/app/com.touguyun-2/base.apk”],nativeLibraryDirectories=[/data/app/com.touguyun-2/lib/arm, /data/app/com.touguyun-2/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 com.touguyun.activity.MainActivity.onToolsClick(MainActivity.java:119)

at com.touguyun.view.MainBottomToolsView$1.onClick(MainBottomToolsView.java:154)

at android.view.View.performClick(View.java:5207)

at android.view.View$PerformClick.run(View.java:21177)

at android.os.Handler.handleCallback(Handler.java:742)

at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:154)

at android.app.ActivityThread.main(ActivityThread.java:5524)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:740)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)

Suppressed: java.lang.ClassNotFoundException: com.touguyun.kotlin.KotlinTest
at java.lang.Class.classForName(Native Method)
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
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available


#2

In my case I fixed it by using implementation instead of provide for my annotation library.
provided ‘com.github.zeroarst.callbackfragment:library:0.3’ -> implementation 'com.github.zeroarst.callbackfragment:library:0.3’
kapt ‘com.github.zeroarst.callbackfragment:compiler:0.3’