2

我正在开发一个基于 android 的小型项目(我对系统很陌生)。当我在 Android 模拟器上运行代码时,它崩溃了,我得到了noClassDefFoundError. 我尝试导入的 .jar 是一个非常简单的类,编写为 Java 项目。错误不是 Android 依赖项或“lib/libs”。

.jars(我从 dropboxAPI 导入)工作得很好(在获得依赖关系之后),但同样的修复不适用于我的 .jar。

有谁知道我做错了什么?

// S verker

[2012-11-22 20:25:58 - DropDoList] Android Launch!
[2012-11-22 20:25:58 - DropDoList] adb is running normally.
[2012-11-22 20:25:58 - DropDoList] Performing com.example.dropdolist.DropDoList activity launch
[2012-11-22 20:25:58 - DropDoList] Automatic Target Mode: using existing emulator    'emulator-5554' running compatible AVD 'Galaxy2v3'
[2012-11-22 20:25:58 - DropDoList] WARNING: Application does not specify an API level requirement!
[2012-11-22 20:25:58 - DropDoList] Device API version is 16 (Android 4.1.2)
[2012-11-22 20:25:58 - DropDoList] Uploading DropDoList.apk onto device 'emulator-5554'
[2012-11-22 20:26:02 - DropDoList] Installing DropDoList.apk...
[2012-11-22 20:26:11 - DropDoList] Success!
[2012-11-22 20:26:11 - DropDoList] Starting activity com.example.dropdolist.DropDoList on device emulator-5554
[2012-11-22 20:26:12 - DropDoList] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]  cmp=com.example.dropdolist/.DropDoList }
[2012-11-22 20:41:10 - DropDoList] Dx 
trouble processing:
[2012-11-22 20:41:10 - DropDoList] Dx bad class file magic (cafebabe) or version (0033.0000)
...while parsing Tester/Transaction.class
...while processing Tester/Transaction.class
[2012-11-22 20:41:10 - DropDoList] Dx 
trouble processing:
[2012-11-22 20:41:10 - DropDoList] Dx bad class file magic (cafebabe) or version (0033.0000)
...while parsing test/Tester.class
...while processing test/Tester.class
[2012-11-22 20:41:10 - DropDoList] Dx 2 warnings
4

1 回答 1

0

您将获得Dx bad class file magic (cafebabe) or version两门课程。此错误不会停止构建过程。相反,它会默默地从最终编译的 apk 中排除这些文件。

如果您使用(比如说)Java 5 并且您使用的是使用 Java 6 编译的 JAR,您将收到此错误。

最简单的解决方法是将您的 Java 版本升级到 JAR 使用的版本。Project -> Properties -> Java Compiler您可以通过转到并选中该Enable project specific settings框并更改Compiler compliance level:值来更改用于构建的版本。

Android 工具不能很好地与 Java 7 配合使用,并且@Override在使用 Java 5 时会出现大量错误,因此我建议使用 Java 6(在编译器合规性下拉列表中为 1.6)。如果它不存在,您可能需要重新安装它。

于 2012-11-22T19:57:46.453 回答