Android 亚马逊设备消息存根!安卓工作室

Android 亚马逊设备消息存根!安卓工作室,android,android-studio,android-gradle-plugin,build.gradle,amazon-device-messaging,Android,Android Studio,Android Gradle Plugin,Build.gradle,Amazon Device Messaging,我正在尝试将Amazon设备消息与Android Studio集成。首先我跟着()。当我打电话时 ADM adm = new ADM(getActivity()); if (adm.isSupported()) { // ... } logcat上有以下输出: E/AndroidRuntime(24472):java.lang.RuntimeException:Stub E/AndroidRuntime(24472):在com.amazon.device.messaging.ADM(未

我正在尝试将Amazon设备消息与Android Studio集成。首先我跟着()。当我打电话时

ADM adm = new ADM(getActivity());
if (adm.isSupported()) {
    // ...
}
logcat上有以下输出:

E/AndroidRuntime(24472):java.lang.RuntimeException:Stub

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

所以我跟随Amazons()得到了同样的结果

然后我尝试了,但没有成功

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

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

你有什么想法吗?

在依赖项部分,你可能有类似的想法:

compile fileTree(include: ['*.jar'], dir: 'libs')
这意味着您正在将
libs
文件夹中的所有JAR编译到您的应用程序中。因此,答案可能是将
compile
切换到
provided
有效,但除了
provided
之外,您还需要对libs文件夹中的所有jar进行
编译


您需要手动删除
文件树
行,并包括所有jar(不包括
amazon-device-messaging-1.0.1.jar
)。

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

  • 删除行:compilefiletree(包括:['.jar'],dir:'libs')*
  • 转到libs文件夹,找出您需要的所有jar文件
  • 将它们逐一纳入汇编。例如,编译文件('libs/ePOS2.jar')
  • 添加ADM jar文件提供的文件('libs/amazon-device-messaging-1.0.1.jar')
  • 建设项目

  • 您是否在Kindle设备上运行该应用程序?是!kindle fire hdx.com是否可以附加完整的build.gradle文件,或者至少附加flavor/buildConfig部分和完整依赖项部分?