Search code examples
androidadb

ADB throws SecurityException while starting service after system update to Nexus 7: "Caller uid=2000 is not privileged to communicate with user=-2"


I am issuing following command to Nexus 7 tablet:

adb.exe -s 015d2109567231a0f shell am startservice -n com.packagename/.ExServiceName --ei port 59777

and getting:

Starting service: Intent { cmp=com.packagename/.ExServiceName (has extras) }
java.lang.SecurityException: Caller uid=2000 is not privileged to communicate with user=-2
    at android.os.Parcel.readException(Parcel.java:1425)
    at android.os.Parcel.readException(Parcel.java:1379)
    at android.app.ActivityManagerProxy.startService(ActivityManagerNative.java:2648)
    at com.android.commands.am.Am.runStartService(Am.java:415)
    at com.android.commands.am.Am.run(Am.java:111)
    at com.android.commands.am.Am.main(Am.java:82)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
    at dalvik.system.NativeStart.main(Native Method)

It all worked without problems until I applied a system update to my tablet!

Current tablet information:

Model number: Nexus 7
Android version: 4.2
Kernel version: 3.1.10-g22b4fcd

Service manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.packagename"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
    <uses-permission android:name="android.permission.INTERNET"/>

    <application android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/AppTheme">

        <service android:name=".ExServiceName" android:exported="true"></service>

    </application>

</manifest>

I am developing under Windows 7 x64

Can you please tell me how to make the service successfully accept the intent without throwing exceptions of any kind?

Thanks,
Konrad


Solution

  • I got the same exception on a Galaxy Nexus which version is Android 4.2.

    I succeeded to start a service by the following command.

    am startservice --user 0 -a <action>