Android 8.0上的Android崩溃Oreo:SecurityException:Permission Denial:null要求以用户450身份运行,但是从用户0调用

时间:2017-08-23 17:25:12

标签: android android-8.0-oreo

我将手机升级到Android Oreo。当我在这台设备上运行我的应用程序时。我的应用程序崩溃了。虽然它在Android 7和更低的设备上运行良好。

这是日志:

E/AndroidRuntime: FATAL EXCEPTION: main
                                                         Process: com.test.test, PID: 28271
                                                         java.lang.SecurityException: Permission Denial: null asks to run as user 450 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS
                                                             at android.os.Parcel.readException(Parcel.java:1942)
                                                             at android.os.Parcel.readException(Parcel.java:1888)
                                                             at android.view.autofill.IAutoFillManager$Stub$Proxy.addClient(IAutoFillManager.java:326)
                                                             at android.view.autofill.AutofillManager.ensureServiceClientAddedIfNeededLocked(AutofillManager.java:896)
                                                             at android.view.autofill.AutofillManager.notifyViewExited(AutofillManager.java:487)
                                                             at android.view.View.notifyEnterOrExitForAutoFillIfNeeded(View.java:6945)
                                                             at android.view.View.dispatchAttachedToWindow(View.java:17413)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326)
                                                             at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1658)
                                                             at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
                                                             at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
                                                             at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
                                                             at android.view.Choreographer.doCallbacks(Choreographer.java:723)
                                                             at android.view.Choreographer.doFrame(Choreographer.java:658)
                                                             at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
                                                             at android.os.Handler.handleCallback(Handler.java:789)
                                                             at android.os.Handler.dispatchMessage(Handler.java:98)
                                                             at android.os.Looper.loop(Looper.java:164)
                                                             at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                             at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

3 个答案:

答案 0 :(得分:18)

我遇到过这个问题。

就我而言,在执行results之后,应用程序抛出了以下异常:

startActivity

经过数小时的调查,我发现我的班级Fatal Exception: java.lang.SecurityException: Permission Denial: null asks to run as user 66853 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS at android.os.Parcel.readException(Parcel.java:1942) at android.os.Parcel.readException(Parcel.java:1888) at android.view.autofill.IAutoFillManager$Stub$Proxy.addClient(IAutoFillManager.java:326) at android.view.autofill.AutofillManager.ensureServiceClientAddedIfNeededLocked(AutofillManager.java:896) at android.view.autofill.AutofillManager.notifyViewExited(AutofillManager.java:487) at android.view.View.notifyEnterOrExitForAutoFillIfNeeded(View.java:6945) at android.view.View.dispatchAttachedToWindow(View.java:17413) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3326) at android.view.ViewGroup.addViewInner(ViewGroup.java:4955) at android.view.ViewGroup.addView(ViewGroup.java:4746) at android.view.ViewGroup.addView(ViewGroup.java:4686) at android.support.v7.widget.RecyclerView$5.addView(RecyclerView.java:711) at android.support.v7.widget.ChildHelper.addView(ChildHelper.java:107) at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:7877) at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7835) at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7823) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1565) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3025) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1308) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.widget.ScrollView.onMeasure(ScrollView.java:350) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:21998) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721) at android.view.View.measure(View.java:21998) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1498) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 已经被所有应用程序活动扩展,实现了一个名为BaseActivity的受保护方法,如下例所示:

getUserId

我刚刚将方法名称更改为另一个,并且应用程序重新开始工作:

 class BaseActivity extends AppCompatActivity {

   ...

   protected int getUserId() {
     return getCurrentUserRepository().getId();
   }
 }

我在基类中找不到任何具有相同名称的方法,但我们可以在stacktrace中看到,此方法可能由反射调用。

其他重要的想法是只有实现任何 class BaseActivity extends AppCompatActivity { ... protected int getApplicationUserId() { return getCurrentUserRepository().getId(); } } 视图的活动才会抛出异常。在 API 26 中实施Autofill Framework后出现此问题。

答案 1 :(得分:0)

总结this回答,并查看UserHandle.java的来源,我们看到了框架用户ID的含义。

# | @UserIdInt            | Value  | Status     | Description |
# | --------------------- | ------ | ---------- | ------------| 
# | USER_OWNER            | 0      | deprecated | "owner" user of the device
# | USER_SYSTEM           | 0      | ok         | "system" user of the device
# | USER_ALL              | -1     | ok         | ALL users on the device
  | USER_CURRENT          | -2     | ok         | the currently active user
# | USER_CURRENT_OR_SELF  | -3     | ok         | id from which we would like to send to the current user
# | USER_NULL             | -10000 | ok         | An undefined user id

然后,要了解android:protectionLevel="signature"的含义,您必须阅读有关permission-element的页面。表中总结了这一点:

enter image description here

因此,您在AndroidManifest.xml中需要做的事情很大程度上取决于您需要支持哪些API,因为更高的>对于非正常(“危险”)权限,23 API也需要android:permissionGroup= definition ...

为了能够举行 INTERACT_ACROSS_USERS ,您的应用必须由固件的签名密钥签名,或者必须安装在系统分区上。

为了能够举行 INTERACT_ACROSS_USERS_FULL ,您的应用必须通过固件的签名密钥进行签名。

因此最后在您的清单文件中添加:

<permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" android:protectionLevel="signature"/>

希望它有所帮助...

答案 2 :(得分:0)

我在科特林遇到了同样的问题。仅当在活动中实现Edittext且该类或其父类中具有getUserId()方法时,才会发生此问题。将 getUserId()更改为 getUserIdd()可以解决我的问题。

在Kotlin中,我有一个变量

var userId=0

我将其更改为

var userIdd=0

解决了我的问题。