版本为4.0的本机电子邮件应用程序在4.0版中运行,它将显示以下异常:
W/dalvikvm( 1308): VFY: unable to resolve static field 31 (CONTENT_URI) in Landroid/provider/Calendar$Calendars;
D/dalvikvm( 1308): VFY: replacing opcode 0x62 at 0x0014
E/AccountManager( 1308): Listener was not previously added
W/dalvikvm( 1308): threadid=13: thread exiting with uncaught exception (group=0x40c391f8)
V/EmailProvider( 1308): EmailProvider.query: uri=content://com.screenshare.email.provider/account/2, match is 2
E/AndroidRuntime( 1308): FATAL EXCEPTION: SyncManager
E/AndroidRuntime( 1308): java.lang.NoClassDefFoundError: android.provider.Calendar$Calendars
E/AndroidRuntime( 1308): at com.screenshare.exchange.SyncManager$CalendarObserver.<init>(SyncManager.java:704)
E/AndroidRuntime( 1308): at com.screenshare.exchange.SyncManager.registerCalendarObserver(SyncManager.java:655)
E/AndroidRuntime( 1308): at com.screenshare.exchange.SyncManager.checkMailboxes(SyncManager.java:2138)
E/AndroidRuntime( 1308): at com.screenshare.exchange.SyncManager.run(SyncManager.java:1949)
E/AndroidRuntime( 1308): at java.lang.Thread.run(Thread.java:856)
Calendar API是否已从4.0中删除?如何使2.3电子邮件应用程序在4.0中成功运行?或者它无法解决?
答案 0 :(得分:2)
我知道原因:日历提供程序已在4.0中进行了更改。在2.3中,日历提供程序为android.provider.Calendar
,在4.0中,日历提供程序为android.provider.CalendarContract
。因此,如果未修改源代码,则无法在4.0中成功运行。
答案 1 :(得分:0)
为任何版本的android
运行代码if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD) {
use android.provider.Calendar
}else{
use android.provider.CalendarContract
}