问题描述
我有一个配备Android 21的Nexus 5设备.我正在毫无问题地测试我的项目.但是,如果我在使用Google API 19的仿真器上进行测试,则会显示错误java.lang.NoClassDefFoundError
.如果在Lollipop上运行良好,怎么会发生此错误?我什至用索尼4.4设备问了我的朋友,它在手机上也崩溃了.我的Compile SDK版本为21,构建工具设置为21.1.2.我尝试了gradle clean,并且正在使用Android Studio.任何帮助将不胜感激.
I have a Nexus 5 device with Android 21 on it. I am testing my project on it with no problem. However, if I test on an Emulator with Google APIs 19 it shows the error java.lang.NoClassDefFoundError
. How could this error occur if it is running well on Lollipop? I even asked my friend with a Sony 4.4 device and it also crashes on his phone. I have my Compile SDK version to 21 and Build Tools set to 21.1.2. I tried gradle clean and I am working on Android Studio. Any help would be highly appreciated.
此错误仅在低于Lollipop的设备上发生:
这是Logcat中显示的内容:
This is what appears in Logcat:
02-10 07:46:19.200 2238-2238/com.myproject.android.indonesia E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myproject.android.indonesia, PID: 2238
java.lang.NoClassDefFoundError: com.myproject.android.indonesia.task.GetProjectTask$1
at com.myproject.android.indonesia.task.GetProjectTask.execute(GetProjectTask.java:27)
at com.myproject.android.indonesia.activity.SplashActivity.launchProjectTask(SplashActivity.java:111)
at com.myproject.android.indonesia.activity.SplashActivity.onCreate(SplashActivity.java:71)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
以下是调用getProjectTask()的代码段
Here is the snippet that calls the getProjectTask()
GetProjectTask mGetProjectTask = new GetProjectTask(this);
mGetProjectTask.mUrl.append(Constants.Link.HOST).append(Constants.Webservice.GET_PROJECT);
mGetProjectTask.params.put(Constants.Key.PRJ_LICENCE, Constants.Constant.LICENCE);
mGetProjectTask.params.put(Constants.Key.LANGUAGE, currentLanguage);
mGetProjectTask.params.put(Constants.Key.CTY_NAME, Constants.Value.APP_CTY_NAME);
mGetProjectTask.execute();
更新似乎我需要使用我正在使用的一种SDK的最新版本来避免此错误(Aviary SDK).升级后,此错误不再出现.
UPDATEIt seems that I needed to use the latest version of one of the SDKs I am using to avoid this error (Aviary SDK). When I upgraded, this error did not appear anymore.
推荐答案
您的类(GetProjectTask
中的第一个匿名类)扩展了该平台上不可用的类.
Your class (the first anonymous class in GetProjectTask
) extends a class that is not available on that platform.
这篇关于低于Lollipop的Android版本上的java.lang.NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!