我有以下异常跟踪。
Fatal Exception: java.lang.RuntimeException: Unable to create application com.myapp.MyApplication: java.lang.SecurityException: Unable to start service Intent { cmp=com.myapp/.background.MyService }: Unable to launch app com.myapp/10232 for service Intent { cmp=com.myapp/.background.MyService }: user 0 is restricted
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.access$1600(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1438)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5408)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by java.lang.SecurityException: Unable to start service Intent { cmp=com.myapp/.background.MyService }: Unable to launch app com.myapp/10232 for service Intent { cmp=com.myapp/.background.MyService }: user 0 is restricted
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1728)
at android.app.ContextImpl.startService(ContextImpl.java:1701)
at android.content.ContextWrapper.startService(ContextWrapper.java:516)
at com.myapp.MyApplication.onCreate(MyApplication.java:105)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4685)
at android.app.ActivityThread.access$1600(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1438)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5408)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
关于这个例外的任何线索?看起来,应用程序是从访客用户安装的,并试图在管理员帐户中访问?我从 OPPO R7 PLUS 设备中得到了这个异常。
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.myapp">
<application
android:name=".MyApplication"
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<service android:name=".background.MyService" />
</application>
</manifest>