Android 无法启动aidl服务:java.lang.SecurityException:不允许启动服务意图

Android 无法启动aidl服务:java.lang.SecurityException:不允许启动服务意图,android,aidl,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.MainA


当我尝试从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上的源代码:


首先,我打开aidl应用程序(它有可以运行服务的进程),然后运行尝试远程运行此服务的clientapp。

如果我遗漏了什么,请告诉我?

根据您收到的错误,我认为您忘记在客户端应用程序的清单文件内部服务标签中添加
android:exported=“true”


我希望这会有所帮助。

确保您的aidl客户端位于同一个包中。是的,所有aidl文件都位于同一个包中。。您可以检查源代码。这很有用: