- edited description
java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
I am trying to use this library but have run into an issue. App details: java version 1.8.0_60 minSdkVersion 12 targetSdkVersion 20 Android Studio 1.4 JRE 1.7.0
When calling for instance: public MP3File getmp3details (File mp3track){
MP3File f = null;
try {
f = (MP3File) AudioFileIO.read(mp3track);
MP3AudioHeader audioHeader = f.getMP3AudioHeader();
audioHeader.getTrackLength();
audioHeader.getSampleRateAsNumber();
audioHeader.getChannels();
audioHeader.isVariableBitRate();
audioHeader.getTrackLengthAsString();
audioHeader.getMpegVersion();
audioHeader.getMpegLayer();
audioHeader.isOriginal();
audioHeader.isCopyrighted();
audioHeader.isPrivate();
audioHeader.isProtected();
audioHeader.getBitRate();
audioHeader.getEncodingType();
} catch (CannotReadException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TagException e) {
e.printStackTrace();
} catch (ReadOnlyFileException e) {
e.printStackTrace();
} catch (InvalidAudioFrameException e) {
e.printStackTrace();
}
return f;
}
I get a FATAL EXCEPTION
10-12 13:17:20.950 14194-14194/com.flyingdutchman.newplaylistmanager E/AndroidRuntime: FATAL EXCEPTION: main
10-12 13:17:20.950 14194-14194/com.flyingdutchman.newplaylistmanager E/AndroidRuntime: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
10-12 13:17:20.950 14194-14194/com.flyingdutchman.newplaylistmanager E/AndroidRuntime: at org.jaudiotagger.audio.mp3.LameFrame.parseLameFrame(LameFrame.java:75)
10-12 13:17:20.950 14194-14194/com.flyingdutchman.newplaylistmanager E/AndroidRuntime: at org.jaudiotagger.audio.mp3.XingFrame.<init>(XingFrame.java:105)
Clicking at org.jaudiotagger.audio.mp3.LameFrame.parseLameFrame(LameFrame.java:75)
bring up the following:
public static LameFrame parseLameFrame(ByteBuffer bb) {
ByteBuffer lameHeader = bb.slice();
String id = Utils.getString(lameHeader, 0, 4, StandardCharsets.ISO_8859_1);
lameHeader.rewind();
if(id.equals("LAME")) {
LameFrame lameFrame = new LameFrame(lameHeader);
return lameFrame;
} else {
return null;
}
}
Question: I could not find anything on this but should my app use a higher minSdk? How do I resolve this? Thank you in advance. Theo
Comments (9)
-
repo owner -
repo owner java.nio.charset.StandardCharsets was introduced in Java 1.7, before 2.4 jaudiotagger would work on Java 1.5 but now it needs 1.7. From what you say your are using Java 1.7, however you are on Android which is somewhat non-standard.
So either you are not using 1.7, or you are using it but Android 1.7 doesn't have this class i which case try a later version. Let me know how you get on.
-
checked java version to make sure. It is as stated. Android Studio is latest version too. Which part you suggest I get a later version of, Android Studio?
-
repo owner Sorry I dont use Android, but perhaps check the Android jdk to see if the java.class nio.charset.StandardCharsets exists
-
repo owner - changed status to invalid
An issue with user setup and/or ANdroid - would be interested to hear what the solution was.
-
Reason for has something to do with https://developer.android.com/reference/java/nio/charset/StandardCharsets.html has been added at API 19. My api is minSdk version is 12. I will have to find an alternative. Thank you for your assistance. Regards Theo http://www.playlistmanager.webspace.virginmedia.com/npm/
-
repo owner Okay thankyou for letting me know, you could use jaudiotagger-2.2.3 instead this doesnt depend on this class, but you wont get aif/wav support plus some bug fixes.
-
Hi,
also have the same problem, device is on API 18 and crashes with the same exception.
How about just using Charset.forName("ISO_8859_1") instead?
Thanks for your work!
-
repo owner The new method is better and I expect to use other methods from Java 7 and Java 8 soon. But if you cant upgrade from API 18 you can use jaudiotagger-2-2-3
- Log in to comment