I have no idea what I am doing wrong.
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.
EDIT
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!
You can fix NoClassDefFoundError error by checking following: Check the exception stack trace to know exactly which class throw the error and which is the class not found by java.
It is thrown by the Java Runtime System when the class definition is not found at run time. Developers can handle an exception using a try and catch block or any other method for preventing the program from crashing. The program will crash whenever NoClassDefFoundError will occur.
NoClassDefFoundError is a common error in Java that occurs if a ClassLoader cannot find a particular class in the classpath while trying to load it. The Exception in thread "main" suggests that this error has occurred in the main thread, the thread which is responsible for running the Java application.
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.)
It's not clear what path you're looking for, or what you're going to do with the result, but consider using File
.
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.
java.nio.file.Paths
is part of the J7 API. Whereas Android (I believe) is built on J6. So, as such you'll be unable to use such classes. The File
class is more than capable usually :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With