需要帮助在AndroidStudio2.3.3中设置Kotlin

时间:2017-09-11 12:21:06

标签: android classnotfoundexception android-studio-2.3 kotlin-android-extensions

在我的Android Studio 2.3.3中,我安装了Kotlin插件,然后创建了一个kotlin类活动。当我补充并运行该Activity时,我得到ClassNotFoundException。我确认我已经在清单文件中添加了新的Activity。

我第一次尝试使用Android的Kotlin,并且不确定是否需要更改gradle文件中的任何内容以使用Kotlin。

以下是我的错误日志:

FATAL EXCEPTION: main
Process: com.example.chandan.myapplication, PID: 16035
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.chandan.myapplication/com.example.chandan.myapplication.RegistrationActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.chandan.myapplication.RegistrationActivity" on path: DexPathList[[zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/base.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/lib/x86, /system/lib, /system/vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.chandan.myapplication.RegistrationActivity" on path: DexPathList[[zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/base.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/lib/x86, /system/lib, /system/vendor/lib]]

1 个答案:

答案 0 :(得分:1)

您还需要将kotlin插件添加到根项目build.gradle和app-module build.gradle。

按照以下网址获取详细信息: -

http://www.limbaniandroid.com/2017/06/setup-kotlin-plugin-for-android-studio.html