无法启动aidl服务:java.lang.SecurityException:不允许启动服务Intent

时间:2018-02-27 11:47:54

标签: android aidl


当我尝试从clientapp启动我的AIDL应用程序服务时,出现以下错误:

FATAL EXCEPTION: main
        Process: rajusugale.dev.clientmodule, PID: 5873
        java.lang.RuntimeException: Unable to start activity ComponentInfo{rajusugale.dev.clientmodule/rajusugale.dev.clientmodule.MainActivity}: java.lang.SecurityException: Not allowed to start service Intent { cmp=rajusugale.dev.myaidllibrary/.CoffeeMakerRemoteService } without permission not exported from uid 10096
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

代码:

Intent serviceIntent = new Intent()
                            .setComponent(new ComponentName(
                                    "rajusugale.dev.myaidllibrary", "rajusugale.dev.myaidllibrary.CoffeeMakerRemoteService"));
    mLog.setText("Starting service…\n");
    startService(serviceIntent);
    mLog.append("Binding service…\n");
    bindService(serviceIntent, mConnection, BIND_AUTO_CREATE);


Github上的来源:
https://github.com/RajuSE/aidl-remote-service


首先,我打开aidl应用程序(其中包含可以运行服务的进程),然后运行尝试远程运行此服务的clientapp。
如果我遗失了什么,请告诉我?

1 个答案:

答案 0 :(得分:1)

基于错误,您会发现我忘记了在客户端应用程序服务标签内的清单文件中添加android:exported="true"

我希望这会有所帮助。