在我的项目属性中,我将 Jaudiotagger.jar 添加为外部存档。Eclipse 检测它拥有的类。这是我的示例代码:
protected void onListItemClick(ListView l, View v, int position, long id) {
Cursor cl = ((SimpleCursorAdapter)l.getAdapter()).getCursor();
cl.moveToPosition(position);
String loc = cl.getString(cl.getColumnIndex(MediaStore.MediaColumns.DATA));
try {
AudioFile f = AudioFileIO.read(new File(loc));
Tag tag = f.getTag();
AudioHeader h = f.getAudioHeader();
Toast.makeText(this, tag.getFirst(FieldKey.ALBUM), Toast.LENGTH_SHORT).show();
}
catch (Exception e){}
当我单击任何列表项(实际上是一个音频文件)时,应用程序崩溃。这是 logcat 日志:
02-06 18:19:52.039: W/dalvikvm(32310): threadid=1: thread exiting with uncaught exception (group=0x40c751f8)
02-06 18:19:52.049: E/AndroidRuntime(32310): FATAL EXCEPTION: main
02-06 18:19:52.049: E/AndroidRuntime(32310): java.lang.NoClassDefFoundError: org.jaudiotagger.audio.AudioFileIO
02-06 18:19:52.049: E/AndroidRuntime(32310): at com.niteesh.album.art.MainActivity.onListItemClick(MainActivity.java:51)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.widget.AdapterView.performItemClick(AdapterView.java:292)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.widget.AbsListView.performItemClick(AbsListView.java:1181)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2709)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.widget.AbsListView$1.run(AbsListView.java:3464)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.os.Handler.handleCallback(Handler.java:605)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.os.Handler.dispatchMessage(Handler.java:92)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.os.Looper.loop(Looper.java:137)
02-06 18:19:52.049: E/AndroidRuntime(32310): at android.app.ActivityThread.main(ActivityThread.java:4511)
02-06 18:19:52.049: E/AndroidRuntime(32310): at java.lang.reflect.Method.invokeNative(Native Method)
02-06 18:19:52.049: E/AndroidRuntime(32310): at java.lang.reflect.Method.invoke(Method.java:511)
02-06 18:19:52.049: E/AndroidRuntime(32310): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
02-06 18:19:52.049: E/AndroidRuntime(32310): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
02-06 18:19:52.049: E/AndroidRuntime(32310): at dalvik.system.NativeStart.main(Native Method)
我还添加TagOptionSingleton.getInstance().setAndroid(true);
了 SO 的另一个线程中提到的内容。然后当我点击项目时,它说
java.lang.NoClassDefFoundError: org.jaudiotagger.tag.TagOptionSingleton;
有人可以帮助我哪里出错了吗?