1

目前项目目标sdk是google api level 14,运行良好。如果我在 android manifest 文件中将目标 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
4

1 回答 1

1

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

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

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

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

将此行放在您的<application>标签上方。或者,如果您还有其他权限条目,那么这些其他条目在哪里。

这些权限是在 API 级别 16 中添加的。例如,请参见值 READ_CALL_LOG 的文档

于 2013-05-24T06:24:34.970 回答