question

kiran-igo avatar image
kiran-igo asked

Exception on trying to init ADM

I get: java.lang.RuntimeException: Stub! at com.amazon.device.messaging.ADM. (Unknown Source) when trying to construct the ADM object on a Kindle Fire HD(System version: 7.3.1_user_3140720). Any ideas what I could be missing?
amazon device messaging
1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I am getting the same error on my API 22 Fire TV (i.e., Amazon AFTB, Lollipop, 5.1.1). However, when I run the exact same app on API 25 Fire TV (i.e., Amazon AFTN, Nougat 7.1.2) it runs absolutely fine with no RuntimeException.

Here is my build.gradle

apply plugin: 'com.android.application'android {
                   
compileSdkVersion 26defaultConfig {
applicationId "com.anas.myapplication"minSdkVersion 15targetSdkVersion 26versionCode 1versionName "1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}

signingConfigs {
debug {
storeFile file("sample.jks")
storePassword 'anasanas'keyAlias 'key0'keyPassword 'anasanas'}
}

buildTypes {
release {
minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'implementation 'com.android.support.constraint:constraint-layout:1.0.2'testImplementation 'junit:junit:4.12'androidTestImplementation 'com.android.support.test:runner:1.0.1'androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'compile files('libs/amazon-device-messaging-1.0.1.jar')
}

Please help me resolve this fast.

0 Likes 0 ·
stephen-the-amazonian avatar image
stephen-the-amazonian answered
Thanks for your question. That exception can occur when you have included the ADM JAR in the APK. Instead, the JAR should just be included in the compiler's classpath. Please see https://developer.amazon.com/sdk/adm/setup.html for more information on the setup process. Thanks, Stephen
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kiran-igo avatar image
kiran-igo answered
Thanks. It looks like the jar file was being copied twice. Once into our ext_libs folder for our lib and then later into the app's libs folder which caused it to be packaged into the APK. Kiran
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

fuzzandroid avatar image
fuzzandroid answered
How do you do this on IntelliJ IDEA?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Fuzzandroid, Thank you for writing to us. In intellij you have to add ADM jar as dependency and scope should be "provided". Go to Project Structure (Ctrl+Alt+Shift+S), select "modules" from "Project Settings" in the left pane, select "Dependencies" tab from right pane. Click on "+" button, select jars or directories, then locate and select the ADM jar, change the scope of the jar as "provided". Make sure "export" check box is not checked.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

OnAir_Player avatar image
OnAir_Player answered
Hi, I followed your instructions to add the ADM library on intellijIDEA but now I get this issue: java.lang.NoClassDefFoundError: com.myapp.services.ADMIntentService any idea why this is happening and how to fix it?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Which device you are testing on? And when the exception is thrown? Can you please paste the full logs? Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

William Erickson avatar image
William Erickson answered
Have you updated your AndroidManifest.xml following these instructions? https://developer.amazon.com/public/apis/engage/device-messaging/tech-docs/04-integrating-your-app-with-adm#Update%20Your%20App%20Manifest I think you might be missing:
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Alexander Farber avatar image
Alexander Farber answered
dependencies {
    compileOnly files('libs/amazon-device-messaging-1.0.1.jar')
    implementation files('libs/login-with-amazon-sdk.jar')
}
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

newuser-529a81eb-d5d7-4f71-b849-eba5c8921239 avatar image
newuser-529a81eb-d5d7-4f71-b849-eba5c8921239 answered

I have had the same issue. Problem was in xml namespace in manifest.

It should be like in documentation: xmlns:amazon="http://schemas.amazon.com/apk/res/android"

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.