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

纵饮孤独 提交于 2019-12-01 18:04:46

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.

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.

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