Android Studio runtime error Stub! at com.amazon.device.messaging.ADMMessageReceiver.<init>()
Asked Answered
G

3

5

When I build the Amazon (Kindle) flavor of my Android app I run into this Runtime error:

Caused by: java.lang.RuntimeException: Stub!
at com.amazon.device.messaging.ADMMessageReceiver.<init>()

I need the local amazon-device-messaging.jar file to compile my app, however I do not need to include it during runtime as the amazon device will have the necessary classes and methods.

How do I update my Android Studio build.gradle file to do this?

Gynecoid answered 3/7, 2014 at 18:11 Comment(0)
M
5

I also ran into this issue. When adding the Amazon Device Messaging jar as a library, Android Studio automatically generated

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

I just needed to switch that to

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

That did the trick for me. I'd up-vote your answer, @Clu, but I don't have a high enough reputation.

Morvin answered 3/7, 2014 at 22:59 Comment(5)
Thanks! Maybe I don't need the additional configurations details. I'll try removing it to see if it still works.Gynecoid
Looks like your simpler answer is the correct way to do this, thanks!Gynecoid
I have the ADM jar inside an android-library project, though I have mentioned the dependency of the ADM jar as provided inside the build.grade file of the android-library project. Its am still getting this error. Any help?Overstuff
@Overstuff did you ever figure this out. This didn't work for me either?Pliske
Neither it worked for me guys! Did you find something ?Likeminded
G
5

To solve this I used the provided type of dependency.

Inside my project modules build.gradle file, right before my dependencies closure I included the following:

configurations {
    provided
}

sourceSets {
    main {
        compileClasspath += configurations.provided
    }
}

And then, within my dependencies closure I included the following:

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

This ensured that the .jar was only used for compile time and not runtime. I'm quite new to Android Studio, and this took me a while to figure out; hopefully this will help you make the switch to Android Studio as well.

Gynecoid answered 3/7, 2014 at 18:11 Comment(1)
If the library and the call to the library are in different packages, the 'provided' will be ignored and the stubbed-out library will instead be compiled into the APK anyway. This can be resolved by putting the library in a Maven repo.Symphonize
M
5

I also ran into this issue. When adding the Amazon Device Messaging jar as a library, Android Studio automatically generated

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

I just needed to switch that to

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

That did the trick for me. I'd up-vote your answer, @Clu, but I don't have a high enough reputation.

Morvin answered 3/7, 2014 at 22:59 Comment(5)
Thanks! Maybe I don't need the additional configurations details. I'll try removing it to see if it still works.Gynecoid
Looks like your simpler answer is the correct way to do this, thanks!Gynecoid
I have the ADM jar inside an android-library project, though I have mentioned the dependency of the ADM jar as provided inside the build.grade file of the android-library project. Its am still getting this error. Any help?Overstuff
@Overstuff did you ever figure this out. This didn't work for me either?Pliske
Neither it worked for me guys! Did you find something ?Likeminded
P
1
  1. Add the ADM jar in the Maven local repository.

Command :

            mvn install:install-file "-Dfile=amazon-device-messaging-1.0.1.jar" "-DgroupId=com.amazon.device.messaging" "-DartifactId=amazondevicemessaging" "-Dversion=1.0.1" "-Dpackaging=jar"
  1. Include local maven repository as project dependency :

Add “mavenLocal()” in main Gradle build script:

            allprojects {
            repositories {
                            mavenCentral()
                            mavenLocal()
             }
  1. Link the Maven artifact in ADM project.

Add below line ADMWrapperLib Gradle script (::).

            provided 'com.amazon.device.messaging:amazondevicemessaging:1.0.1'
Pointillism answered 4/5, 2015 at 10:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.