简体   繁体   English

应用程序在模拟器上运行良好,但在设备上显示NoClassDefFoundError

[英]Application runs fine on emulator but gives NoClassDefFoundError on device

I have developed an app and it runs as expected on the emulator, but gives error while I run it in my device(HTC one X). 我已经开发了一个应用程序,它可以在模拟器上按预期运行,但是在我的设备(HTC one X)中运行它时出现错误。 Below is the error as shown in the logcat. 下面是在logcat中显示的错误。 There is a method which creates a notification. 有一种创建通知的方法。 Error appears when this method createNotification() is invoked. 调用此方法createNotification()时出现错误。 Logcat is below: Logcat如下:

11-09 13:40:13.350: E/AndroidRuntime(5294): FATAL EXCEPTION: main
11-09 13:40:13.350: E/AndroidRuntime(5294): java.lang.NoClassDefFoundError: android.app.TaskStackBuilder
11-09 13:40:13.350: E/AndroidRuntime(5294):     at com.example.accessibility.Accessibility.createNotification(Accessibility.java:205)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at com.example.accessibility.Accessibility$1.onClick(Accessibility.java:69)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at android.view.View.performClick(View.java:3538)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at android.view.View$PerformClick.run(View.java:14319)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at android.os.Handler.handleCallback(Handler.java:608)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at android.os.Looper.loop(Looper.java:156)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at android.app.ActivityThread.main(ActivityThread.java:5045)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at java.lang.reflect.Method.invokeNative(Native Method)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at java.lang.reflect.Method.invoke(Method.java:511)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-09 13:40:13.350: E/AndroidRuntime(5294):     at dalvik.system.NativeStart.main(Native Method)

I would appreciate if someone can help me fix this error. 如果有人可以帮助我解决此错误,我们将不胜感激。

TaskStackBuilder is available starting from API level 16 (Android 4.1 otherwise known as Jellybean). TaskStackBuilder从API级别16(Android 4.1,否则称为Jellybean)开始可用。 Your HTC One X has Android 4.0 on it. 您的HTC One X装有Android 4.0。

Did you recently updated your eclipse android plugin (adt r17)? 您最近是否更新了eclipse android插件(adt r17)? Then the following link might help: 然后,以下链接可能会有所帮助:

How to fix the classdefnotfounderror with adt-17 如何使用adt-17修复classdefnotfounderror

If not then post some code. 如果没有,则发布一些代码。

As mentioned by @David Wasser TaskStackBuilder was added in API Level 16 (Android 4.1) 如@David Wasser所述,TaskStackBuilder已添加到API级别16(Android 4.1)中

You can solve your problem by adding import android.support.v4.app.TaskStackBuilder; 您可以通过添加import android.support.v4.app.TaskStackBuilder;解决问题android.support.v4.app.TaskStackBuilder; instead of import android.app.TaskStackBuilder; 而不是import android.app.TaskStackBuilder;

make sure your app having either v4 / v7 support library added 确保您的应用添加了v4 / v7支持库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android数据库应用程序在模拟器上运行良好,但在设备上显示错误 - Android database application runs fine on emulator but gives an error on the device 我的应用程序可以在仿真器2.1 / 2.2上正常运行,但不能在2.2设备上运行 - My application runs fine on emulator 2.1/2.2 but not on a 2.2 device 应用程序在模拟器上运行正常,但在真实设备上崩溃 - App runs fine on emulator, but crashes on real device 应用程序在模拟器上运行良好,但在设备上崩溃 - App runs fine on emulator but crashes on device 应用程序在模拟器上运行,但不在真实设备上运行 - Application runs on emulator but not in real device 应用程序在设备上运行,但在模拟器上崩溃? - Application runs on Device but crashes on Emulator? 应用程序最终在模拟器上运行,但不在设备上运行 - Application ultimately runs on Emulator but not on device 数据库在模拟器中工作正常,但在设备上出错 - Database works fine in emulator, but gives an error on device Android应用程序可以在模拟器中正常运行,但不能在真实设备中运行? - Android application works fine in emulator but not in real device? Android应用程序可以在模拟器上正常运行,但不能在真实设备上运行 - Android Application works fine on emulator but not on a real device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM