3

I'm trying the Amazon Device Messaging API

I added the jar file using the import as suggested by Amazon. When I deploy onto the device, I get an error,

06-03 16:24:13.680: E/AndroidRuntime(11038): java.lang.NoClassDefFoundError: com.amazon.device.messaging.ADM
06-03 16:24:13.680: E/AndroidRuntime(11038):    at com.myapp.MainActivity.onCreate(MainActivity.java:74)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.app.Activity.performCreate(Activity.java:4635)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.app.ActivityThread.access$600(ActivityThread.java:126)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1172)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.os.Looper.loop(Looper.java:137)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at android.app.ActivityThread.main(ActivityThread.java:4586)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at java.lang.reflect.Method.invokeNative(Native Method)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at java.lang.reflect.Method.invoke(Method.java:511)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-03 16:24:13.680: E/AndroidRuntime(11038):    at dalvik.system.NativeStart.main(Native Method)

I cannot add the jar file to the order & export as it causes stub error and not recommended by Amazon.

They say when the app is installed, it should pick the apis from the device instead its searching for the class files in the app causing this issue.

I tried building from eclipse IDE and also manually using ANT.

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
dcanh121
  • 4,665
  • 11
  • 37
  • 84

3 Answers3

2

Please check your manifeat file in there you might have put following code out side the application tag

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

this lines must be inside the application tag.

if You are using Android Studio than you should keep in mind this

Change from this:

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

to this:

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

Thanks!

Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113
  • Jignesh I am also getting the same issue. Actually i am running the same application on android mobile (not kindle tab) which has amazon appstore installed in it. I have integrated ADM in the app. It is working fine on kindle emulators. Please tell me if you require any other info. – Gem Jan 28 '14 at 08:52
  • I could not get what is your problem – Jignesh Ansodariya Jan 28 '14 at 11:20
  • Ok Let me explain my issue: I have a application which is currently live on play store and amazon app store (not optimized for kindle). Now i want to add push notification feature for that i have added ADM code. Now when i test it on kindle emulator i works fine but when i run it on android devices it crashed with same stack trace as @dcanh121 provided in question. And it is quite obvious. I cannot add the jar file to the order & export as it causes stub error. So what could be the solution ? – Gem Jan 28 '14 at 17:30
  • You should remove jar file first and also remove from lib directory also, than go to Libraries tab and click Add External Jars..(second button) and select jar file from other directory (out side of the project). Hope it will work. – Jignesh Ansodariya Jan 29 '14 at 04:23
  • @JigneshAnsodariya Even with same tag its give same error in android studio. Any idea? – Keyur Thumar Jul 02 '17 at 12:42
  • @Keyur Thumar I edited my answer, please let me know if this is useful to you or notl – Jignesh Ansodariya Jul 03 '17 at 04:58
  • @JigneshAnsodariya I got the problem - AMD will not work in all android device. Check this link - https://developer.amazon.com/public/apis/engage/device-messaging/tech-docs/adm-faq – Keyur Thumar Jul 03 '17 at 05:15
  • Yes, AMD will only run on FireOS or amazon devices! – Fahad-Android Dec 16 '21 at 12:22
0

I just want to add that one cause of this error could be that you're trying to setup ADM on a non-Kindle/Fire device. I came here under the assumption that all Amazon store apps could use ADM, but no, just Amazon devices.

HoratioCain
  • 915
  • 9
  • 19
0

You are missing below lines in Manifest

<!-- Your application's API Key -->
<meta-data android:name="AmazonAPIKey" android:value=""/>

<!--  Declare your ADMMessageHandlerBase implementation as a service -->
<service android:name="com.cbsnews.ott.adm.ADMMessageHandler"
    android:exported="false" />

<!-- You must explicitly enable ADM. You must also declare whether your application will run with or without ADM.
If you specify android:required="false", your app must degrade gracefully when ADM is unavailable. -->
<amazon:enable-feature android:name="com.amazon.device.messaging"
    android:required="true" />

<receiver android:name="com.cbsnews.ott.adm.ADMMessageHandler$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="com.amazonaws.kindletest"/>
    </intent-filter>
</receiver>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Amit Patel
  • 1,795
  • 16
  • 20