10

我正在尝试将 Amazon Device Messaging 与 Android Studio 集成。首先我跟着(integration-your-app-with-adm)。当我打电话

ADM adm = new ADM(getActivity());
if (adm.isSupported()) {
    // ...
}

logcat 上有这样的输出:

E/AndroidRuntime(24472): java.lang.RuntimeException: 存根!

E/AndroidRuntime(24472):在 com.amazon.device.messaging.ADM.(未知来源)

所以我跟着 Amazons ( Integrating Amazon Libraries with Android Studio ) 得到了同样的结果。

然后我尝试了这个这个没有成功。

我的 AndroidManifest.xml 看起来像这样:

...
<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>

本地 build.gradle 如下所示:

...

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

你有什么想法吗?

4

2 回答 2

14

您的依赖项部分中可能有类似的内容:

compile fileTree(include: ['*.jar'], dir: 'libs')

这意味着您正在将libs文件夹中的所有 jar 编译到您的应用程序中。所以可能说切换compileprovided工作的答案,但除了providedcompile对 libs 文件夹中的所有罐子做之外。

您需要删除该行,并手动fileTree包含您在那里拥有的任何罐子(不包括)。amazon-device-messaging-1.0.1.jar

于 2015-09-24T12:53:52.277 回答
2

修复崩溃的解决方案是编辑 build.gradle (Module:app) 文件。

  1. 删除行:compile fileTree(include: [' .jar'], dir: 'libs')*
  2. 转到libs文件夹并找出您需要的所有 jar 文件
  3. 将它们一一包含以进行编译。例如编译文件('libs/ePOS2.jar')
  4. 添加 ADM jar 文件提供的文件('libs/amazon-device-messaging-1.0.1.jar')
  5. 构建项目
于 2018-02-16T05:46:43.203 回答