my application is built with kotlin,here is my build.gradle file:
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
and my workspace's build.gradle file:
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"
}
in my project,I already use java8 with jack, so the gradle-plugin version can only be 1.1.1
when I start my application, it crashes randomly,here is the log:
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
override
fun initData() { mPagerAdapter = MainFragmentAdapter(supportFragmentManager, this) }
the crash happens in the init of the mPageAdapter, the constructor of the MainFragmentPagerAdapter is below:
class MainFragmentAdapter : FragmentPagerAdapter { private val mContext: Context constructor(fm: FragmentManager, context: Context) : super(fm) { mContext = context }
can somebody help me out,thx a lot!
To fix Android apps that keep crashing: To do this, go to Settings and open Apps. Under Your apps, you'll see a list of the apps currently installed on your device. From the list, tap the app that keeps crashing and tap Force stop in the bottom right corner. Then try opening the app again.
Many devices feature lots of storage, but your app may crash if you have too many apps and data files taking up space. An easy way to solve this problem is to check for apps you haven't used for a long time and uninstall them. You can also use Android apps to clean up old and unwanted files from the device.
Adding the following as an app-level dependency fixed it for me:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
--- EDIT ---
This has now been superseded by:
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With