androidserviceaidl

Android AIDL - Unable to start service Intent


The error I am receiving is

2022-01-28 11:10:42.186 1651-3045/? W/ActivityManager: Unable to start service Intent { act=nveeaidle pkg=com.rchan.nveeapplication } U=0: not found

I have ensured the following code in both my applications (client and server). In my server manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rchan.nveeapplication">

    <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.NveeApplication">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name="com.rchan.nvee_sdk.detectedactivity.DetectedActivityService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="nveeaidle" />
            </intent-filter>
        </service>

        <receiver android:name="com.rchan.nvee_sdk.detectedactivity.DetectedActivityReceiver"/>
<!--        <receiver-->
<!--            android:name="com.rchan.nvee_sdk.detectedactivity.DetectedActivityReceiver"-->
<!--            android:exported="false"-->
<!--            android:process=":remote"-->
<!--            android:permission="com.google.android.gms.permission.ACTIVITY_RECOGNITION">-->
<!--            <intent-filter>-->
<!--                <action android:name="action.TRANSITIONS_DATA" />-->
<!--            </intent-filter>-->
<!--        </receiver>-->
    </application>

</manifest>

In my client, I have this in my fragment:

private fun connectToRemoteService() {
        val intent = Intent("nveeaidle")
        val pack = "com.rchan.nveeapplication"
        pack?.let {
            intent.setPackage(pack)
            activity?.applicationContext?.bindService(
                intent, this, Context.BIND_AUTO_CREATE
            )
        }
    }

I am not sure what is causing this warning, and I have tried out different solutions after searching on stackoverflow and google.

How do I test is:

  1. Launch my server application
  2. Launch my client application
  3. I see the warning

Thank you for taking the time to read my question.


Solution

  • I did more searching and finally found the answer... All credits go to the SO answer here:

    https://stackoverflow.com/a/55712326/3718584

    TLDR:

    Had to change the intent from implicit to explicit due to API 21

    intent.setClassName("com.rchan.nveeapplication","com.rchan.nvee_sdk.detectedactivity.DetectedActivityService")