gpt4 book ai didi

Android 4.4.4 上的 java.lang.noClassDefFoundError,适用于 5.0+

转载 作者:太空狗 更新时间:2023-10-29 14:03:05 24 4
gpt4 key购买 nike

我收到这个错误:

12-17 03:59:18.767 7516-8610/io.ustube.ustube E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: io.ustube.ustube, PID: 7516
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NoClassDefFoundError: com.google.gson.internal.$Gson$Preconditions
at com.google.gson.reflect.TypeToken.<init>(TypeToken.java:72)
at com.google.gson.reflect.TypeToken.get(TypeToken.java:296)
at com.google.gson.Gson.toJson(Gson.java:644)
at com.google.gson.Gson.toJson(Gson.java:631)
at com.google.gson.Gson.toJson(Gson.java:586)
at com.google.gson.Gson.toJson(Gson.java:566)
at io.ustube.ustube.LoginActivity$VerifyTask.doInBackground(LoginActivity.java:338)
at io.ustube.ustube.LoginActivity$VerifyTask.doInBackground(LoginActivity.java:310)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 

但我知道提到的类是一个依赖项。我自己查看了 jar 文件。另外,我只在 5.0 以下出现此错误。

我的 gradle 文件包括 compile 'com.google.code.gson:gson:2.5'

最佳答案

NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. For example, if we have a method call from a class or accessing any static member of a Class and that class is not available during run-time then JVM will throw NoClassDefFoundError.

你可以试试

compile 'com.google.code.gson:gson:2.3'

然后,修改您的应用 Gradle 构建文件配置以包含支持库并启用 multidex 输出。

    android {
compileSdkVersion 21 // Set Yours
buildToolsVersion "21.1.0" // Set Yours

defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21 // Set Yours
...

// Enabling multidex support.
multiDexEnabled true
}
...
}

dependencies {
compile 'com.android.support:multidex:1.0.0'
}

更多详情

DexIndexOverflowException Only When Running Tests

关于Android 4.4.4 上的 java.lang.noClassDefFoundError,适用于 5.0+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34330529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com