Answer the question
In order to leave comments, you need to log in
Why am I getting a java.lang.NoClassDefFoundError error?
I have a code that downloads songs. There he is:
try (BufferedInputStream in = new BufferedInputStream(new URL(urlStr).openStream());
FileOutputStream fileOutputStream = new FileOutputStream(file)) {
byte dataBuffer[] = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
fileOutputStream.write(dataBuffer, 0, bytesRead);
}
} catch (IOException e) {
// handle exception
}
Mp3File mp3file = null;
try {
mp3file = new Mp3File(file);
} catch (IOException e) {
e.printStackTrace();
} catch (UnsupportedTagException e) {
e.printStackTrace();
} catch (InvalidDataException e) {
e.printStackTrace();
}
if (mp3file.hasId3v1Tag()) {
mp3file.removeId3v1Tag();
}
if (mp3file.hasId3v2Tag()) {
mp3file.removeId3v2Tag();
}
if (mp3file.hasCustomTag()) {
mp3file.removeCustomTag();
}
ID3v2 id3v2Tag;
if (mp3file.hasId3v2Tag()) {
id3v2Tag = mp3file.getId3v2Tag();
} else {
// mp3 does not have an ID3v2 tag, let's create one..
id3v2Tag = new ID3v24Tag();
mp3file.setId3v2Tag(id3v2Tag);
}
id3v2Tag.setTrack("5");
id3v2Tag.setArtist(performer);
id3v2Tag.setTitle(title);
id3v2Tag.setAlbum("Lalala");
id3v2Tag.setYear("2001");
id3v2Tag.setGenre(12);
id3v2Tag.setArtistUrl(songImg.getText().toString());
try {
id3v2Tag.setAlbumImage(recoverImageFromUrl(songImg.getText().toString()),"");
} catch (Exception e) {
e.printStackTrace();
}
E/AndroidRuntime: FATAL EXCEPTION: Timer-2
Process: music.player.musicplayer.audio.media.fm.video.radio.video.songs.equalizer.apps.free.android.lalala.download.search, PID: 31039
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/nio/file/Paths;
at com.mpatric.mp3agic.FileWrapper.<init>(FileWrapper.java:21)
at com.mpatric.mp3agic.Mp3File.<init>(Mp3File.java:57)
at com.mpatric.mp3agic.Mp3File.<init>(Mp3File.java:45)
at musicplayer.audioplayer.equalizer.mp3player.widget.TopAdapter$TopViewHolder$4.run(TopAdapter.java:292)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.nio.file.Paths" on path: DexPathList
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.mpatric.mp3agic.FileWrapper.<init>(FileWrapper.java:21)
at com.mpatric.mp3agic.Mp3File.<init>(Mp3File.java:57)
at com.mpatric.mp3agic.Mp3File.<init>(Mp3File.java:45)
at musicplayer.audioplayer.equalizer.mp3player.widget.TopAdapter$TopViewHolder$4.run(TopAdapter.java:292)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question