question

bugdroid avatar image
bugdroid asked

Trouble with Maps and Android Studio (provided jar)

I posted this over 24 hours ago and figured I would start a new thread to try and get it some attention. I am testing on a fire phone. The summary of the issue is that there are no working instructions for including the amazon maps jar as "provided" in Android Studio. https://forums.developer.amazon.com/forums/thread.jspa?messageID=12092⼼ Here is the content of the post: I am, like many users posting in this thread, frustrated by the lack of documentation for Amazon Maps and Android Studio. Can someone from Amazon update this page: https://developer.amazon.com/appsandservices/apis/engage/maps/doc/building-and-testing-your-maps-app#Configuring To be up to date for Android Studio? I was including my jar in my project which allowed me to compile but gave a runtime Stub error. Looking at the instructions in the above link for IntelliJ I can't follow them as parts of those instructions do not exist in Android Studio. How do I add the 1.0.2 amazonmaps JAR to my Android Studio project as a provided dependency? After removing the jar from my project I can no longer build because com.amazon.geo.maps is an unresolved symbol. Following the instructions at the link above, I get to step 3 but there is no "Project Settings" or "Modules" to click. Making my best guess and going to step 4, there is no "My Maps Module". Guessing you mean my module that requires Maps I continue but when I get to "Jars or directories" this option does not exist. Etc. I am using Android Studio 0.8.0. One thing I did try was to create a folder at the same level as libs called "provided-libs". I put the amazonmaps jar in it. I went to Project Structure and added a File Dependency for the JAR (you can't select a folder) and made it Provided. This led to the project compiling, but a runtime Stub exception. I also tried to modify the build.gradle by hand to have this line in dependencies: provided fileTree(dir: 'provided-libs', include: '*.jar') This led to the project not compiling (package com.amazon.geo.maps does not exist) For reference here are the current Amazon instructions: Configuring Your Project in IntelliJ IDEA In IntelliJ IDEA, create or navigate to your Android project. On the File menu, click Project Structure. Under Project Settings, click Modules. In the list of modules, click your Maps module. Click the Dependencies tab. Click the plus (+) button. Click Jars or directories. Navigate to the directory where you downloaded the Mobile App SDK, and then open the Android/Maps/lib folder. Select the JAR file for the Amazon Maps API, and then click OK. In the newly created entry for the JAR file, under Scope, click the default value and change it to Provided. Important: Be sure to click Provided. The JAR file contains stub implementations of the Amazon Maps API. It does not contain actual implementations of the Maps API classes, so you should not compile the JAR into your app. Click OK to save your changes and close the Project Structure dialog box.
fire phone
10 |5000

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

1 Answer

bugdroid avatar image
bugdroid answered
Well, I finally got this to work and thought I would share the solution that worked for me and explain why it appears to not have worked. My android project consists of many libraries and I was modifying build.gradle in a library project. Once I made these changes to the main project my project compiled and did not have the Stub! error at runtime. 1) make "provided-libs" folder in root of main project, put amazonmaps jar in it 2) modify build.gradle of main project to include: dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile project(':Something') provided files('provided-libs/amazonmaps-1.0.2.jar') }
10 |5000

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