android 中的 JAudiotagger java.lang.VerifyError
JAudiotagger java.lang.VerifyError in android
我正在尝试创建一个参考这些的音频标签编辑器
http://www.jthink.net/jaudiotagger/
和
JAudioTagger and Android - Change a value in an mp3?
和
Jaudiotagger ID3 TAG for android - can set artwork but cannot set other fields
需要将哪个库导入到项目中,这样我就不会得到java.lang.VerifyError
我正在尝试使用这个库编写代码
jaudiotagger-2.2.5.jar
我从这里找到的
https://bitbucket.org/ijabz/jaudiotagger/downloads
这是代码
try {
File file = new File(Data);
TagOptionSingleton.getInstance().setAndroid(true);
AudioFile audioFile = AudioFileIO.read(file);
Tag newTag = audioFile.getTag();
newTag.setField(FieldKey.ALBUM,"October");
newTag.setField(FieldKey.ARTIST,"U2");
audioFile.commit();
} catch (CannotReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TagException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReadOnlyFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAudioFrameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CannotWriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这是日志猫
12-07 16:56:10.618: D/dalvikvm(738): GC_FOR_ALLOC freed 137K, 11% free 6210K/6919K, paused 59ms
12-07 16:56:11.358: I/dalvikvm(738): Could not find method org.jaudiotagger.tag.TagOptionSingleton.getInstance, referenced from method com.example.scrlltabs3.songManagerDialog.onClick
12-07 16:56:11.358: W/dalvikvm(738): VFY: unable to resolve static method 11628: Lorg/jaudiotagger/tag/TagOptionSingleton;.getInstance ()Lorg/jaudiotagger/tag/TagOptionSingleton;
12-07 16:56:11.368: D/dalvikvm(738): VFY: replacing opcode 0x71 at 0x0009
12-07 16:56:11.368: W/dalvikvm(738): VFY: unable to resolve exception class 1667 (Lorg/jaudiotagger/audio/exceptions/CannotReadException;)
12-07 16:56:11.378: W/dalvikvm(738): VFY: unable to find exception handler at addr 0x2b
12-07 16:56:11.378: W/dalvikvm(738): VFY: rejected Lcom/example/scrlltabs3/songManagerDialog;.onClick (Landroid/view/View;)V
12-07 16:56:11.378: W/dalvikvm(738): VFY: rejecting opcode 0x0d at 0x002b
12-07 16:56:11.388: W/dalvikvm(738): VFY: rejected Lcom/example/scrlltabs3/songManagerDialog;.onClick (Landroid/view/View;)V
12-07 16:56:11.388: W/dalvikvm(738): Verifier rejected class Lcom/example/scrlltabs3/songManagerDialog;
12-07 16:56:11.388: D/AndroidRuntime(738): Shutting down VM
12-07 16:56:11.398: W/dalvikvm(738): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-07 16:56:11.428: E/AndroidRuntime(738): FATAL EXCEPTION: main
12-07 16:56:11.428: E/AndroidRuntime(738): java.lang.VerifyError: com/example/scrlltabs3/songManagerDialog
12-07 16:56:11.428: E/AndroidRuntime(738): at com.example.scrlltabs3.songManagerDialog.onCreate(songManagerDialog.java:68)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.Activity.performCreate(Activity.java:4465)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.access0(ActivityThread.java:122)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.os.Looper.loop(Looper.java:137)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-07 16:56:11.428: E/AndroidRuntime(738): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 16:56:11.428: E/AndroidRuntime(738): at java.lang.reflect.Method.invoke(Method.java:511)
12-07 16:56:11.428: E/AndroidRuntime(738): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-07 16:56:11.428: E/AndroidRuntime(738): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-07 16:56:11.428: E/AndroidRuntime(738): at dalvik.system.NativeStart.main(Native Method)
阅读错误,很容易指出下面这行是导致Verify
错误的原因
TagOptionSingleton.getInstance().setAndroid(true);
Could not find method
org.jaudiotagger.tag.TagOptionSingleton.getInstance, referenced from
method com.example.scrlltabs3.songManagerDialog.onClick
谷歌搜索问题我遇到了以下 Whosebug question/answer,它描述了相同的问题并通过替换提供了解决方案:
audioFile.commit();
与
AudioFileIO.write(audioFile)
请参阅 here 问题和上述解决方案。如果这解决了您的问题,请不要忘记给回答者 Paul Taylor 投赞成票。
java.lang.verifyError 当 JVM 的字节码验证程序在执行前尝试验证所有字节码并在发现不一致时失败并且这些不一致可能由于许多因素而增加作为
- 在 运行 时间内针对一个库进行编译并使用另一个库
- 单独编译 class 有其他 classes 依赖它
- 教程link中列出的其他内容
可以找到关于 VerifyError 的详细解释和示例 here。
请参阅上面的示例 link,其中演示了 JVM 是如何抛出验证错误的。
我正在尝试创建一个参考这些的音频标签编辑器
http://www.jthink.net/jaudiotagger/
和
JAudioTagger and Android - Change a value in an mp3?
和
Jaudiotagger ID3 TAG for android - can set artwork but cannot set other fields
需要将哪个库导入到项目中,这样我就不会得到java.lang.VerifyError
我正在尝试使用这个库编写代码
jaudiotagger-2.2.5.jar
我从这里找到的
https://bitbucket.org/ijabz/jaudiotagger/downloads
这是代码
try {
File file = new File(Data);
TagOptionSingleton.getInstance().setAndroid(true);
AudioFile audioFile = AudioFileIO.read(file);
Tag newTag = audioFile.getTag();
newTag.setField(FieldKey.ALBUM,"October");
newTag.setField(FieldKey.ARTIST,"U2");
audioFile.commit();
} catch (CannotReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TagException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReadOnlyFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAudioFrameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CannotWriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这是日志猫
12-07 16:56:10.618: D/dalvikvm(738): GC_FOR_ALLOC freed 137K, 11% free 6210K/6919K, paused 59ms
12-07 16:56:11.358: I/dalvikvm(738): Could not find method org.jaudiotagger.tag.TagOptionSingleton.getInstance, referenced from method com.example.scrlltabs3.songManagerDialog.onClick
12-07 16:56:11.358: W/dalvikvm(738): VFY: unable to resolve static method 11628: Lorg/jaudiotagger/tag/TagOptionSingleton;.getInstance ()Lorg/jaudiotagger/tag/TagOptionSingleton;
12-07 16:56:11.368: D/dalvikvm(738): VFY: replacing opcode 0x71 at 0x0009
12-07 16:56:11.368: W/dalvikvm(738): VFY: unable to resolve exception class 1667 (Lorg/jaudiotagger/audio/exceptions/CannotReadException;)
12-07 16:56:11.378: W/dalvikvm(738): VFY: unable to find exception handler at addr 0x2b
12-07 16:56:11.378: W/dalvikvm(738): VFY: rejected Lcom/example/scrlltabs3/songManagerDialog;.onClick (Landroid/view/View;)V
12-07 16:56:11.378: W/dalvikvm(738): VFY: rejecting opcode 0x0d at 0x002b
12-07 16:56:11.388: W/dalvikvm(738): VFY: rejected Lcom/example/scrlltabs3/songManagerDialog;.onClick (Landroid/view/View;)V
12-07 16:56:11.388: W/dalvikvm(738): Verifier rejected class Lcom/example/scrlltabs3/songManagerDialog;
12-07 16:56:11.388: D/AndroidRuntime(738): Shutting down VM
12-07 16:56:11.398: W/dalvikvm(738): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-07 16:56:11.428: E/AndroidRuntime(738): FATAL EXCEPTION: main
12-07 16:56:11.428: E/AndroidRuntime(738): java.lang.VerifyError: com/example/scrlltabs3/songManagerDialog
12-07 16:56:11.428: E/AndroidRuntime(738): at com.example.scrlltabs3.songManagerDialog.onCreate(songManagerDialog.java:68)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.Activity.performCreate(Activity.java:4465)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.access0(ActivityThread.java:122)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.os.Looper.loop(Looper.java:137)
12-07 16:56:11.428: E/AndroidRuntime(738): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-07 16:56:11.428: E/AndroidRuntime(738): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 16:56:11.428: E/AndroidRuntime(738): at java.lang.reflect.Method.invoke(Method.java:511)
12-07 16:56:11.428: E/AndroidRuntime(738): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-07 16:56:11.428: E/AndroidRuntime(738): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-07 16:56:11.428: E/AndroidRuntime(738): at dalvik.system.NativeStart.main(Native Method)
阅读错误,很容易指出下面这行是导致Verify
错误的原因
TagOptionSingleton.getInstance().setAndroid(true);
Could not find method org.jaudiotagger.tag.TagOptionSingleton.getInstance, referenced from method com.example.scrlltabs3.songManagerDialog.onClick
谷歌搜索问题我遇到了以下 Whosebug question/answer,它描述了相同的问题并通过替换提供了解决方案:
audioFile.commit();
与
AudioFileIO.write(audioFile)
请参阅 here 问题和上述解决方案。如果这解决了您的问题,请不要忘记给回答者 Paul Taylor 投赞成票。
java.lang.verifyError 当 JVM 的字节码验证程序在执行前尝试验证所有字节码并在发现不一致时失败并且这些不一致可能由于许多因素而增加作为
- 在 运行 时间内针对一个库进行编译并使用另一个库
- 单独编译 class 有其他 classes 依赖它
- 教程link中列出的其他内容
可以找到关于 VerifyError 的详细解释和示例 here。
请参阅上面的示例 link,其中演示了 JVM 是如何抛出验证错误的。