question

Joseph Blough avatar image
Joseph Blough asked

Gradle support

The instructions on building for Ant were very well documented and I was wondering if there were plans to detail building in Gradle. When I try building using Gradle, the amazonmaps-1.0.2.jar is included and I get the "Stub!" error.
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.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Joseph, Thank you for posting. You need to understand a fact to resolve the issue. Basically, amazonmaps.jar only provides the compilation support to your implementation codebase. I mean, to build apk out of your app project, the obvious step you should do is compile (by using javac) your java source. Now you have used our Map classes inside your code. To resolve the usages of these classes, amazonmaps.jar should should be set in compile classpath, But it should not be packaged with your apk as these classes are already available in runtime in all Kindle devices. If you use IDE like eclipse or IntelliJ Idea, these takes care of compilation while building your app's apk. While using build scripting language like Ant, Maven or Gradle you should take care this in the build script. So you must include amazonmaps.jar as an external library. Please refer below link, https://developer.amazon.com/sdk/maps/building.html#Configuring Hope this helps.
10 |5000

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

Joseph Blough avatar image
Joseph Blough answered
Thank you for the response! I'm able to get my app to compile with Eclipse and Ant based on the "Configuring Your Project for Building Your Maps App" instructions on the "Building and Testing Your Maps App" page. They were very helpful! The issue I'm having is that the Gradle build system seems to automatically include any classpath jars in the APK. Searching around, it looks like there are some ways around this by using custom configurations ( http://stackoverflow.com/questions/10405970/how-do-i-define-a-compile-time-only-classpath-in-gradle?rq=1 having the most information). Thanks again!
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 Joseph, This is really wired. I do not know about Gradle but still want to know how packaging works there. So to compile an android project we need to set android.jar (the one comes with the android sdk). Do you mean that this jar would also be packaged along with the apk while building with Gradle?
10 |5000

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

Joseph Blough avatar image
Joseph Blough answered
According to the new build system ( http://tools.android.com/tech-docs/new-build-system/user-guide), you can use the line "apply plugin: 'android'" to provide most of the build file. You should be able to have a build file as simple as buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.4.2' } } apply plugin: 'android' android { compileSdkVersion 17 } and usually the amazon maps jar file could be included by adding the line "compile files('../amazonmaps-1.0.2.jar')" to the dependencies section of the build script. Unfortunately, adding the file to dependencies section add the jar file to the APK which causes the "Stub!" error.
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
Thanks Joseph for bringing the issue into notice. Since Gradle build system has been integrated with Android Studio, every one who using this IDE and integrating Amazon Maps in to their apps would start getting the same problem. The link referred by you would be useful for many. However, I'm going to forward this feedback/suggestion to the concern team so that our documentation could have a guild for Gradle build system.
10 |5000

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

bunjix avatar image
bunjix answered
Hello, I have the same issue. It's very anoying to not be able to run application just because your jar need to be set has "provided". Did you figure a way to fix this problem ? 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.

Bipin@Amazon avatar image
Bipin@Amazon answered
There are few recent changes in gradle version, this is useful link http://tools.android.com/recent http://developer.android.com/sdk/installing/studio.html#Revisions http://www.jetbrains.com/idea/webhelp/dependencies-tab.html 1)Compile: The dependency in included in the classpath for your sources and test sources at the compilation and run phases. 2)Test: The dependency is included in the classpath only for your test sources at the compilation and run phases. 3)Runtime: The dependency is included in the classpath for your sources and test sources but only at the run phase. 4)Provided: For your sources, the dependency is included in the classpath only at the compilation phase. This is useful when there is a container (e.g. a web container of an application server) that provides the corresponding dependency at runtime.
10 |5000

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

bunjix avatar image
bunjix answered
Hello, The change make nothing works better for me. And your link does not explain anythings much more. Do you have a sample of project that works for Amazon Maps with a working build.gradle file ? Thanks for help.
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 Bunjix, Thank you for posting. Can you follow the way given in the below stack overflow link to define "compile-only-classpath" using Gradle. http://stackoverflow.com/questions/10405970/how-do-i-define-a-compile-time-only-classpath-in-gradle?rq=1 Have you already tried this? In gradle.build file, configurations{ provided } dependencies{ //Add amazon maps jar here provided '...' } //Include provided for compilation sourceSets.main.compileClasspath += configurations.provided // optional: if using 'idea' plugin idea { module{ scopes.PROVIDED.plus += configurations.provided } } // optional: if using 'eclipse' plugin eclipse { classpath { plusConfigurations += configurations.provided } }
10 |5000

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

Joseph Blough avatar image
Joseph Blough answered
Where would that go in the build script? For our build script we have a root level, a "buildscript" node, and an "android" node. Is there a chance that a working build.gradle file would be added to the Amazon maps sample project? Thank you!
10 |5000

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