question

icoretech avatar image
icoretech asked

java.lang.RuntimeException: Stub!

Hello, our application is under review, we started getting crash reports like this: java.lang.RuntimeException: Unable to instantiate receiver fm.ourapp.android.net.push.adm.Receiver: java.lang.RuntimeException: Stub! Caused by: java.lang.RuntimeException: Stub! at com.amazon.device.messaging.ADMMessageReceiver. () It appears that this is happening on a `TrendMicroMarsAndroidSandbox` device. Our developers says that it's being difficult to trap such exception, I figured this is some kind of automated test sandbox that stubs out the adm functionality, but this is crashing the app I guess. Is there something we can do?
amazon device messaging
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
This question is already answered below. https://forums.developer.amazon.com/forums/thread.jspa?messageID=8415
10 |5000

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

Wenjie Qiao avatar image
Wenjie Qiao answered
I had the same issue. The problem is we don't use Eclipse but Android Studio and gradle to build. There is no such an option to add external jars as eclipse. I thought the gradle equivalent to external jar would be the "provided" under "dependencies" instead of "compile" but it doesn't seem to be working.
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
10 |5000

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

mark chester goking avatar image
mark chester goking answered
im currently having this problem as well. i cant run the app in a stock android device. already installed, the amazon platform apk and home simulator apk the app has home-api.jar and amazonsupport.jar exported in the apk as well (or else i get classnotfoundexception) then i get this error 08-15 10:03:02.020: E/AndroidRuntime(15636): java.lang.RuntimeException: Unable to start activity ComponentInfojava.lang.RuntimeException: Stub! You are bundling a stubbed jar in the apk! Please move it to the classpath instead.
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
Our ADM JAR file only a reference for the compiler to a class that will be resolved at runtime on Kindle Fire(2nd Gen tablets and newer), FireTV and Fire Phone. This jar should not be packaged in your app’s dex file as the runtime class exists on our platform already. In eclipse, in project's the Properties window, there is an "Order and Export" tab for the Java Build Path for your project. Do NOT mark the ADM .jar file as exported in this tab. 
 https://developer.amazon.com/sdk/adm/setup.html#IDE In addition, if you are using the Gradle build system or Android Studio, which is our supported configuration for our Fire Phone builds. We would recommend that as a part of your project’s app target build.gradle file under your dependencies object, you would want to place the ADM JAR in a folder in your project and when you add it in the ‘provided’ scope rather than ‘compile’, which means that it will be a runtime dependency provided by the system your app runs on rather than being compiled into your APK. For example: dependencies{ provided files('libs/amazon-device-messaging-1.0.1.jar') } Assuming that you place the ADM JAR file into a directory called ‘libs’.
10 |5000

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

nyt-junior-dev avatar image
nyt-junior-dev answered
Were you able to fix your problem because it doesn't look like the documentation has been updated.
10 |5000

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

DougM@Amazon avatar image
DougM@Amazon answered
Hello nyt-junior-dev, Unfortunately our official documentation has not been updated for Android Studio. However, if you include the ADM jar as 'provided' for your build target in Android studio instead of compile, this should allow for your app to function as it will use the JAR file purely as a reference and not allow for the stubbed out Java code to be included in your app at build time. If there are more questions about your implementation with Device Messaging , please feel free to follow-up with us.
10 |5000

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

Nick Gardner avatar image
Nick Gardner answered
Note that we have further information now on integrating Amazon APIs, including ADM, with Android Studio: https://forums.developer.amazon.com/forums/thread.jspa?threadID=4872&tstart=0
10 |5000

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