下面是一些我用来访问Build.SERIAL
静态字段的代码,但是在 Android 1.6 上运行时它会崩溃!
// introduced in Android 2.3(API Level 9)
if (Integer.parseInt(android.os.Build.VERSION.SDK) >= android.os.Build.VERSION_CODES.GINGERBREAD) {
deviceID = android.os.Build.SERIAL; //cannot execute here if runs on Android 1.6!!!
}
那是崩溃日志:
DexOpt: couldn't find static field
W/dalvikvm( 1098): VFY: unable to resolve static field 37 (SERIAL) in Landroid/os/Build;
W/dalvikvm( 1098): VFY: rejecting opcode 0x62 at 0x0001
W/dalvikvm( 1098): VFY: rejected Lcom/opera/mini/android/DisplayNotificationService;.getDeviceSerialID ()Ljava/lang/String;
W/dalvikvm( 1098): Verifier rejected class Lcom/opera/mini/android/DisplayNotificationService;
W/dalvikvm( 1098): Class init failed in newInstance call (Lcom/opera/mini/android/DisplayNotificationService;)
D/AndroidRuntime( 1098): Shutting down VM
W/dalvikvm( 1098): threadid=3: thread exiting with uncaught exception (group=0x4001da10)
E/AndroidRuntime( 1098): Uncaught handler: thread main exiting due to uncaught exception`
那么如何解决这个问题呢?