NoClassDefFoundError在ADM上集成Amazon ADM

时间:2013-06-03 23:28:07

标签: java android kindle

我正在尝试亚马逊设备消息传递API

我使用Amazon建议的导入添加了jar文件。当我部署到设备上时,我收到错误,

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)

我无法将jar文件添加到订单&导出,因为它导致存根错误,亚马逊不推荐。

他们说当安装应用程序时,它应该从设备中选择api而不是在应用程序中搜索类文件导致此问题。

我尝试从eclipse IDE构建并手动使用ANT。

3 个答案:

答案 0 :(得分:2)

请检查您的manifeat文件,您可能已将以下代码放在application标记旁边

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

这一行必须在application标记内。

如果您使用的是Android Studio,请记住此

从此改变:

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

到此:

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

谢谢!

答案 1 :(得分:0)

我只想补充一点,导致此错误的原因可能是您尝试在非Kindle / Fire设备上设置ADM。我假设所有亚马逊商店应用都可以使用ADM,但不是亚马逊设备,我来到这里。

答案 2 :(得分:0)

您在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>