更改目标sdk时,Android项目不会运行

时间:2013-05-23 05:24:14

标签: android eclipse

目前项目目标sdk是google api level 14,运行良好。如果我在android清单文件中将目标sdk更改为google api level 16并运行该项目,则会显示消息unfortunately, app has stopped。如果我将它改回到14级,那么它又会运行。

有人可以告诉我这是什么原因吗?

编辑: logcat详细信息

05-24 10:57:09.709: E/Trace(981): error opening trace file: No such file or directory (2) 
05-24 10:57:11.108: E/AndroidRuntime(981): FATAL EXCEPTION: main 
05-24 10:57:11.108: E/AndroidRuntime(981): java.lang.RuntimeException: Unable to create application com.sentry.android.hmi.SentryApp: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.CallLogProvider from ProcessRecord{41321b58 981:com.sentry.android/u0a48} (pid=981, uid=10048) requires android.permission.READ_CALL_LOG or android.permission.WRITE_CALL_LOG 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4154) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.access$1300(ActivityThread.java:130) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Handler.dispatchMessage(Handler.java:99) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Looper.loop(Looper.java:137) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.main(ActivityThread.java:4745) 
05-24 10:57:11.108: E/AndroidRuntime(981): at java.lang.reflect.Method.invokeNative(Native Method) 
05-24 10:57:11.108: E/AndroidRuntime(981): at java.lang.reflect.Method.invoke(Method.java:511) 
05-24 10:57:11.108: E/AndroidRuntime(981): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
05-24 10:57:11.108: E/AndroidRuntime(981): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
05-24 10:57:11.108: E/AndroidRuntime(981): at dalvik.system.NativeStart.main(Native Method) 
05-24 10:57:11.108: E/AndroidRuntime(981): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.CallLogProvider from ProcessRecord{41321b58 981:com.sentry.android/u0a48} (pid=981, uid=10048) requires android.permission.READ_CALL_LOG or android.permission.WRITE_CALL_LOG 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Parcel.readException(Parcel.java:1425) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Parcel.readException(Parcel.java:1379) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2354) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.acquireProvider(ActivityThread.java:4219) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:1703) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1099) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.content.ContentResolver.query(ContentResolver.java:354) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.content.ContentResolver.query(ContentResolver.java:313) 
05-24 10:57:11.108: E/AndroidRuntime(981): at com.sentry.android.hmi.SentryApp.onCreate(SentryApp.java:116) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999) 
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151) 
05-24 10:57:11.108: E/AndroidRuntime(981): ... 10 more

1 个答案:

答案 0 :(得分:1)

您必须将以下行添加到AndroidManifest.xml文件中:

    <uses-permission android:name="android.permission.WRITE_CALL_LOG"/>

如果您只是阅读此日志,请将行更改为:

    <uses-permission android:name="android.permission.READ_CALL_LOG"/>

将此行放在<application>标记的上方。或者,如果您还有其他权限条目,那么其他人也是。

这些权限是使用API​​级别16添加的。例如,请参阅documentation to the value READ_CALL_LOG