最近遇见这样的问题,在打开Android Calendar应用的时候出现这样的信息:
I/ActivityManager( 64): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.calendar/.LaunchActivity } from pid 222
D/PowerManagerService( 64): acquireWakeLock flags=0x1 tag=ActivityManager-Launch
I/ActivityManager( 64): Start proc com.android.calendar for activity com.android.calendar/.LaunchActivity: pid=509 uid=10018 gids={3003}
V/WindowManager( 64): Layout: mDisplayFrozen=false holdScreen=null
I/ActivityManager( 64): Starting: Intent { flg=0x20020000 cmp=com.android.calendar/.MonthActivity } from pid 509
D/PowerManagerService( 64): acquireWakeLock flags=0x1 tag=ActivityManager-Launch
V/WindowManager( 64): Layout: mDisplayFrozen=false holdScreen=null
E/ActivityThread( 509): Failed to find provider info for com.android.calendar
E/ActivityThread( 509): Failed to find provider info for com.android.calendar
E/Cal ( 509): loadEvents() returned null cursor!
W/dalvikvm( 509): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime( 509): FATAL EXCEPTION: main
E/AndroidRuntime( 509): java.lang.NullPointerException
E/AndroidRuntime( 509): at android.util.CalendarUtils$TimeZoneUtils$AsyncTZHandler.onQueryComplete(CalendarUtils.java:93)
E/AndroidRuntime( 509): at android.content.AsyncQueryHandler.handleMessage(AsyncQueryHandler.java:344)
E/AndroidRuntime( 509): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 509): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 509): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 509): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 509): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 509): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
E/AndroidRuntime( 509): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
E/AndroidRuntime( 509): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 64): Force finishing activity com.android.calendar/.MonthActivity
当遇到这样的问题怎么办呢?那就要考虑Calendar应用对应的数据库操作的CalendarProvider。
具体Calendar 应用的源码位置:
packages/apps/Calendar
对应的provider 源码位置:
packages/providers/CalendarProvider
一般情况下出现Failed to find provider info for com.android.calendar的错误,是因为没有安装CalendarProvider.apk 或已经安装但有问题,如果没有安装安装该apk,如果已经安装,确认该apk并重新安装,具体确认的方式如下:
1.删除CalendarProvider安装包必要的的安装信息文件。
$ adb shell
# cd system/app
# ls CalendarProvider*
CalendarProvider.apk
# rm CalendarProvider.apk
# cd ../../data/data
# ls com.android.providers.calendar
databases
shared_prefs
lib
# rm -r com.android.providers.calendar
#exit
$ adb uninstall com.android.providers.calendar
Success
到这里CalendarProvider.apk 已经完全uinstall了
2.重新安装CalendarProvider.apk
$ adb install CalendarProvider.apk(如果不在当前目录的话,你需要将编译出来的apk路径带上,一般的编译出来的路径为:/out/target/product/你的产品名称/system/app/CalendarProvider.apk)。
当我们遇到同样类似于Failed to find provider info for com.android.xxxx 的错误时,我们可以同样的方法找到对应的xxxxProvider.apk 进行确认。