我会很感激一些帮助来弄清楚这个异常消息对我说的到底是什么。我能够使用调试器将问题缩小到代码中的特定行。但是,我认为更多信息可以更好地找出代码中的实际问题。
public static List<ParsedNdefRecord> getRecords(NdefRecord[] records)
{
List<ParsedNdefRecord> elements = new ArrayList<ParsedNdefRecord>();
for (NdefRecord record : records) {
if (UriRecord.isUri(record)) {
elements.add(UriRecord.parse(record));
} else if (TextRecord.isText(record)) {
elements.add(TextRecord.parse(record));
} else if (SmartPoster.isPoster(record)) {
elements.add(SmartPoster.parse(record));
}
}
return elements;
}
09-10 13:47:38.207: D/dalvikvm(332): VFY: replacing opcode 0x71 at 0x000c
09-10 13:47:38.207: D/dalvikvm(332): VFY: dead code 0x000f-004f in Lcom/example/android/nfc/record/UriRecord;.parseWellKnown (Landroid/nfc/NdefRecord;)Lcom/example/android/nfc/record/UriRecord;
09-10 13:47:49.617: W/dalvikvm(332): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/example/android/nfc/record/UriRecord;
09-10 13:48:28.971: D/AndroidRuntime(332): Shutting down VM
09-10 13:48:28.971: W/dalvikvm(332): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-10 13:48:29.178: E/AndroidRuntime(332): FATAL EXCEPTION: main
09-10 13:48:29.178: E/AndroidRuntime(332): java.lang.ExceptionInInitializerError
09-10 13:48:29.178: E/AndroidRuntime(332): at com.example.android.nfc.NdefMessageParser.getRecords(NdefMessageParser.java:48)
09-10 13:48:29.178: E/AndroidRuntime(332): at com.example.android.nfc.NdefMessageParser.parse(NdefMessageParser.java:41)
09-10 13:48:29.178: E/AndroidRuntime(332): at com.example.android.nfc.TagViewer.buildTagViews(TagViewer.java:105)
09-10 13:48:29.178: E/AndroidRuntime(332): at com.example.android.nfc.TagViewer.resolveIntent(TagViewer.java:86)
09-10 13:48:29.178: E/AndroidRuntime(332): at com.example.android.nfc.TagViewer.onCreate(TagViewer.java:59)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.os.Looper.loop(Looper.java:123)
09-10 13:48:29.178: E/AndroidRuntime(332): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-10 13:48:29.178: E/AndroidRuntime(332): at java.lang.reflect.Method.invokeNative(Native Method)
09-10 13:48:29.178: E/AndroidRuntime(332): at java.lang.reflect.Method.invoke(Method.java:507)
09-10 13:48:29.178: E/AndroidRuntime(332): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-10 13:48:29.178: E/AndroidRuntime(332): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-10 13:48:29.178: E/AndroidRuntime(332): at dalvik.system.NativeStart.main(Native Method)
09-10 13:48:29.178: E/AndroidRuntime(332): Caused by: java.lang.NoClassDefFoundError: com.google.common.collect.ImmutableBiMap
09-10 13:48:29.178: E/AndroidRuntime(332): at com.example.android.nfc.record.UriRecord.<clinit>(UriRecord.java:51)
09-10 13:48:29.178: E/AndroidRuntime(332): ... 18 more
09-10 13:48:39.069: I/Process(332): Sending signal. PID: 332 SIG: 9