我收到了Crashlytics中的android.permission.UPDATE_DEVICE_STATS權限的崩潰。我不會在我的應用中請求此權限,因爲我不需要它。我無法重現此問題。應用程序嘗試在ContentResolver中調用查詢方法時發生崩潰。具有權限的Android崩潰UPDATE_DEVICE_STATS
也許有人碰到這個問題,並知道原因或如何解決它。事情發生在銀河J5(2016)
Fatal Exception: java.lang.RuntimeException: Unable to create application com.myapp.App: java.lang.SecurityException: uid 10166 does not have android.permission.UPDATE_DEVICE_STATS.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6326)
at android.app.ActivityThread.access$1800(ActivityThread.java:223)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7231)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by java.lang.SecurityException: uid 10166 does not have android.permission.UPDATE_DEVICE_STATS.
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4240)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:6394)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2380)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1521)
at android.content.ContentResolver.query(ContentResolver.java:486)
at android.content.ContentResolver.query(ContentResolver.java:445)
at com.myapp.wrapper.AppSettingWrapper.getDeviceId(AppSettingWrapper.java:103)
at com.myapp.wrapper.AppSettingWrapper.setNewDeviceId(AppSettingWrapper.java:160)
at com.myapp.App.onCreate(Mail2WorldApplication.java:70)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6323)
at android.app.ActivityThread.access$1800(ActivityThread.java:223)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7231)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
編輯: getDeviceId方法
public static String getDeviceId(Context context){
boolean isNotEnd = true;
String deviceId = "";
while (isNotEnd) { // I guess this loop is needed to refetch data, if the app wasn't able to fetch getDeviceId from the first time
isNotEnd = false;
Uri uriDeviceId = AppSettingsContentProvider.DEVICE_ID_CONTENT_URI;
Cursor cursor = context.getContentResolver().query(uriDeviceId, null, null, null, null);
if(cursor != null){
try {
if(cursor.moveToFirst()) {
deviceId = cursor.getString(0);
}
} catch (CursorIndexOutOfBoundsException e){
isNotEnd = true;
}finally {
cursor.close();
}
}else{
isNotEnd = true;
}
}
return deviceId;
}
我懷疑調用'setNewDeviceId()'意味着你_do_需要'UPDATE_DEVICE_STATS' - 但你贏了」如果不是一個「系統」應用程序,這意味着要麼建立自己的ROM或紮根電話。 – TripeHound
@TripeHound不,setNewDeviceId()這是我的包裝方法。 setNewDeviceId()的內部我把查詢調用到我的內容提供者 – Dima
你可以顯示'com.myapp.wrapper.AppSettingWrapper.getDeviceId(AppSettingWrapper.java:103)'嗎? – AxelH