Question

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.

Was it helpful?

Solution

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!

OTHER TIPS

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.

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top