我的应用程序是使用Kotlin构建的,这是我的build.gradle文件:
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
并且我的工作区的build.gradle文件:
ext.kotlin_version = '1.1.3-2'
ext.kotlin_plugin_version = '1.1.1'
dependencies {
classpath "io.realm:realm-gradle-plugin:3.4.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_plugin_version"
}
在我的项目中,我已经使用了带有jack的Java8,所以gradle-plugin版本只能为1.1.1。但是当我启动应用程序时,它会随机崩溃。以下是日志记录:
FATAL EXCEPTION: main
Process: com.ss.android.caijing.stock.debug, PID: 31962
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at com.ss.android.caijing.stock.main.MainActivity.initData(MainActivity.kt:33)
at com.ss.android.caijing.stock.base.BaseActivity.onCreate(BaseActivity.java:25)
at android.app.Activity.performCreate(Activity.java:6367)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at com.bytedance.frameworks.plugin.hook.InstrumentationHook$PluginInstrumentation.callActivityOnCreate(InstrumentationHook.java:248)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.ss.android.caijing.stock.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ss.android.caijing.stock.debug-1/lib/arm64, /data/app/com.ss.android.caijing.stock.debug-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
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.ss.android.caijing.stock.main.MainActivity.initData(MainActivity.kt:33)
at com.ss.android.caijing.stock.base.BaseActivity.onCreate(BaseActivity.java:25)
at android.app.Activity.performCreate(Activity.java:6367)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at com.bytedance.frameworks.plugin.hook.InstrumentationHook$PluginInstrumentation.callActivityOnCreate(InstrumentationHook.java:248)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Suppressed: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics not found
at com.bytedance.frameworks.plugin.core.DelegateClassLoader.findClass(DelegateClassLoader.java:137)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
Suppressed: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
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)
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.bytedance.frameworks.plugin.core.DelegateClassLoader.findClass(DelegateClassLoader.java:60)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.ss.android.caijing.stock.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ss.android.caijing.stock.debug-1/lib/arm64, /data/app/com.ss.android.caijing.stock.debug-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
private var mPagerAdapter: MainFragmentAdapter? = null
覆盖
fun initData() { mPagerAdapter = MainFragmentAdapter(supportFragmentManager, this) }
在 mPageAdapter 的 init 中发生了崩溃,在此提供 MainFragmentPagerAdapter 构造函数如下:
class MainFragmentAdapter : FragmentPagerAdapter { private val mContext: Context constructor(fm: FragmentManager, context: Context) : super(fm) { mContext = context }
有人可以帮我吗?非常感谢!
MainActivity.kt
的代码,以便我们更好地了解问题。 - pRaNaYprivate var mPagerAdapter: MainFragmentAdapter? = null override fun initData() { mPagerAdapter = MainFragmentAdapter(supportFragmentManager, this) }
崩溃发生在mPageAdapter的init中,MainFragmentPagerAdapter的构造函数如下:class MainFragmentAdapter : FragmentPagerAdapter { private val mContext: Context constructor(fm: FragmentManager, context: Context) : super(fm) { mContext = context }
- Brand Leecompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
。 - Aran Moncusi Ramirez