Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Device Messaging Stub! Android Studio

I'm trying to integrate Amazon Device Messaging with Android Studio. First I followed (integrating-your-app-with-adm). When I call

ADM adm = new ADM(getActivity());
if (adm.isSupported()) {
    // ...
}

There's this output on logcat:

E/AndroidRuntime(24472): java.lang.RuntimeException: Stub!

E/AndroidRuntime(24472): at com.amazon.device.messaging.ADM.(Unknown Source)

So I followed Amazons (Integrating Amazon Libraries with Android Studio ) with the same result.

Then I tried this and this without success.

My AndroidManifest.xml looks like this:

...
<uses-permission android:name="de.mypackage.permission.RECEIVE_ADM_MESSAGE" />
<uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" />
<permission android:name=".permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" />
...
<application
    android:name=".MyPackageApplication"
    android:allowBackup="true"
    android:allowClearUserData="true"
    android:hardwareAccelerated="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
...
    <service android:name=".service.ADMNotificationService" android:exported="false" />

    <amazon:enable-feature android:name="com.amazon.device.messaging" android:required="true" />

    <receiver android:name=".service.ADMNotificationService$MessageAlertReceiver"
        android:permission="com.amazon.device.messaging.permission.SEND">
    <intent-filter>
            <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
            <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
            <category android:name="de.mypackage"/>
        </intent-filter>
    </receiver>
...
</application>

The local build.gradle looks like this:

...

dependencies {
    ...
    provided files('libs/amazon-device-messaging-1.0.1.jar')
    ...
}

May you have an idea?

like image 511
Kartenspieler Avatar asked Aug 04 '15 09:08

Kartenspieler


2 Answers

You probably have something along this lines in your dependencies section:

compile fileTree(include: ['*.jar'], dir: 'libs')

This means you're compiling all jars in libs folder into your app. So probably the answer that says switch compile to provided works, but in addition to provided you do compile for all jars in libs folder anyway.

You would need to remove the fileTree line, and include any jars you have there (excluding amazon-device-messaging-1.0.1.jar) manually.

like image 121
wasyl Avatar answered Sep 24 '22 22:09

wasyl


The solution to fix the crash is to edit the build.gradle (Module:app) file.

  1. Remove the line: compile fileTree(include: ['.jar'], dir: 'libs')*
  2. Go to the libs folder and find out all the jar files you require
  3. Include them one by one for compilation. For example, compile files('libs/ePOS2.jar')
  4. Add ADM jar file provided files('libs/amazon-device-messaging-1.0.1.jar')
  5. Build the project
like image 26
Binu Paul Avatar answered Sep 25 '22 22:09

Binu Paul