androidandroid-intentintentserviceaar

Invoking AAR library service through AIDL throwing Unable to start service intent


I included an aar library in my android application. And whatever activities, services, receivers are there in the library manifest file, I copied it to the Application manifest file.

Now I want to invoke the service of library through AIDL. When I'm starting the service, getting the issue "Unable to start service Intent"

Could some one help what extra I have to do to make it work? How does the OS tells the service is available in the library?

Aar file library package name is "com.abc.lib". The service in aar manifest file:

    <service android:name="com.abc.lib.MyService"
       android:exported="true">
       <intent-filter>
           <action android:name="com.abc.lib.aidl.IMyService"/>
       </intent-filter>
    </service>

Calling the above service from Application Activity file with the below code:

ComponentName compName = null;
Intent i = new Intent("com.abc.lib.aidl.IMyService");
i.setPackage("com.abc.lib");
compName = startService(i);
return compName;

Advance thanks.


Solution

  • Instead of library package in the intent.setPackage, I tried application package, it worked.

    ComponentName compName = null;
    Intent i = new Intent("com.abc.lib.aidl.IMyService");
    i.setPackage("com.abc.application");  //Instead of library package-give the application package
    compName = startService(i);
    return compName;