question

two1stnamz avatar image
two1stnamz asked

Help with MapActivity

Hi, I'm developing an app that's built using gradle. The app is built into two flavors, Google and Amazon. Both flavors define a class called SignupMapActivity, where the Google flavor uses Google Maps, and the Amazon flavor uses Amazon Maps. At build time, gradle pulls in the correct SignupMapActivity class based on the flavor of the app I'm building. The issue I'm having is with the Amazon apk, where launching the SignupMapAcivity works just fine on my 2nd Gen Kindle HD (map tiles and all), but crashes with a NoClassDefFoundError on my 3rd Gen Kindle 8.9 HDX. Any ideas on why this might be?
amazon maps
10 |5000

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

Bipin@Amazon avatar image
Bipin@Amazon answered
The searched-for class definition existed when the map class was compiled, but the definition can no longer be found. Open the Android/Maps/lib folder, and then select the JAR file for the Amazon Maps API.Important: Be sure that you clicked Add External JARs. The JAR file contains stub implementations of the Amazon Maps API. It does not contain actual implementations of the Maps API classes. Do not add the file to your project as a JAR, because this will bundle the stub classes into your app, causing your app to crash.
10 |5000

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

two1stnamz avatar image
two1stnamz answered
Hi Bipin, I have included the Amazon Maps API library jar as provided (instead of compiled) in the gradle script - this should accomplish what is required of the API lib in that it is only required at compile time and NOT runtime. Also, the error here is NoClassDefFoundError on the SignupMapActivity and not a "Stub!" error (which would be caused if I included the lib as compiled). The issue is, the app runs just fine on my 2nd Gen Kindle HD (the activity launches fine and the map renders), but running the same app on my Kindle 8.9 HDX crashes with the following stacktrace: java.lang.NoClassDefFoundError: com.example.android.activity.SignupMapActivity at com.example.android.ui.activity.SignUpActivity$2.onClick(SignUpActivity.java:72) at android.view.View.performClick(View.java:4265) at android.view.View$PerformClick.run(View.java:17604) at android.os.Handler.handleCallback(Handler.java:747) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:151) at android.app.ActivityThread.main(ActivityThread.java:5185) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) The question is, why does the app work just fine on the HD but blow up on the HDX? Thanks! Message was edited by: two1stnamz
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 two1stnamz, That's a wired problem. Are you sure that you are generating the apk once and running it in both the devices? SignupMapActivity is a class which is defined by you in your app. Right? Then how could it be disappeared when you change the runtime? Is SignupMapActivity an extension of any Amazon or Google map class? If you generate different apk for 2nd Gen HD and HDX 8.9, please check the Gradle script that you are using to pull in the correct SignupMapActivity for a platform. If still you have the issue, I may want to take a look on your apk once. Please write back and I will send you a mail so that you can forward me your APK. 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.

two1stnamz avatar image
two1stnamz answered
Haha that's the question: why would the same apk run fine on the HD and blow up on the HDX? SignupMapActivity is defined twice: once for the google flavor (using Google maps), and once for the amazon flavor (using Amazon maps). The gradle script pulls in the correct activity at build time. The amazon flavor of SignupMapActivity extends amazon's MapActivity. Also no, the different kindle devices do no have separate build scripts - they share a single build script.
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
Just sent you a mail.
10 |5000

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