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

独自空忆成欢 提交于 2020-01-11 08:52:07

问题


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?


回答1:


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.




回答2:


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.




回答3:


  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'


来源:https://stackoverflow.com/questions/24560632/android-studio-runtime-error-stub-at-com-amazon-device-messaging-admmessagerece

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!