Android 上的 NoClassDefFoundError [英] NoClassDefFoundError on Android
问题描述
我不知道我做错了什么.
I have no idea what I am doing wrong.
我想在我的 Android 项目中创建一个路径变量,但每次出现 NoClassDefFoundError.
I want to create a path variable in my Android project, but everytime I get a NoClassDefFoundError.
test = test + ".turns"; //This is a simple String
List<String> turnlist = new ArrayList<String>();
Path testfile = (Path) Paths.get(test);
Logcat:
05-13 19:08:51.996: E/AndroidRuntime(23437): FATAL EXCEPTION: Thread-1108
05-13 19:08:51.996: E/AndroidRuntime(23437): Process: com.example.voicerecorder, PID: 23437
05-13 19:08:51.996: E/AndroidRuntime(23437): java.lang.NoClassDefFoundError: java.nio.file.Paths
05-13 19:08:51.996: E/AndroidRuntime(23437): at com.example.voicerecorder.activities.RecordActivity$TestLoader.run(RecordActivity.java:201)
我不知道我做错了什么.
I have no idea what I am doing wrong.
编辑
我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!我再也不会把我的桌面 jre 放到我的 android 类路径中了!
I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath! I will never again put my desktop jre into my android classpath!
推荐答案
您正在尝试使用 java.nio.file.Paths
,其中 据我所知在 Android 中不存在.(仅支持 Java 7 API 的某些部分.)
You're trying to use java.nio.file.Paths
, which doesn't exist in Android as far as I can see. (Only some parts of the Java 7 API are supported.)
不清楚您要查找的路径,或者您将如何处理结果,但请考虑使用 File
.
It's not clear what path you're looking for, or what you're going to do with the result, but consider using File
.
编辑,现在我们知道了更多:您不应该不将桌面 JRE jar 文件放在 Android 项目的类路径中.那只是自找麻烦.如果不这样做,您就会正确地得到一个编译时错误.
Edit, now that we know a bit more: You should not put your desktop JRE jar files in the classpath for an Android project. That's just asking for trouble. Without doing that, you'd have correctly got a compile-time error.
这篇关于Android 上的 NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!