Amazon Device Messaging Stub! Android Studio
Asked Answered
C

2

10

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?

Catalonia answered 4/8, 2015 at 9:40 Comment(3)
Do you run the app on the Kindle device?Damick
Yes! kindle fire hdx.Catalonia
can you attach full build.gradle file or at least flavor/buildConfig sections and full dependencies section?Damick
P
14

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.

Pergola answered 24/9, 2015 at 12:53 Comment(0)
I
2

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
Isiah answered 16/2, 2018 at 5:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.