javaandroidkindleamazon-device-messaging

NoClassDefFoundError Amazon ADM integration on kindle


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.


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!