I had many problems in Android Studio when I tried to create an application with GoogleMap.
I have already followed the following instructions with (almost) no problems, using Eclipse as IDE :
https://developers.google.com/maps/documentation/android/start
I’ve never used Android Studio before and I’m struggling with the project/module paradigm.
I was unable to configure Google Play Services SDK
http://developer.android.com/google/play-services/setup.html.
Here’s one of my strange mistakes:
Cradle:
SAFETY : The design failed with one exception.
*
The task ‘:MyMapApp:compileDebug’ failed.
> Compilation failed; see compiler error output for details.
*
Execute the –stacktrace option to get a stack trace. Use the –info or –debug option to get more output data.
How can I solve this problem?
Solution 1:
I finally managed to get the GoogleMapsAPIv2 project working with Android Studio.
EDIT: As Xavier said, this method only works for projects that are not based on a grader. And the part of the user interface used in this tutorial is excluded from AndroidStudio. So, if you have a custom project that uses the Gradle build system, you will have to edit the build.gradle configuration file manually, because the Android Studio user interface has no control over it.
EDIT2 : With the release of AndroidStudio v0.1.1, the part of the user interface responsible for the module dependencies has been removed, so we currently have to manually update the dependencies via the build.gradle file. The interface for changing factory dependencies will be released in future versions.
EDIT3 : For those who are still trying this approach – please note that it is outdated and no longer works.
I did:
1) I took the sample project from the Google Play service and copied it to a separate folder. It will be our MapsApiV2 project that we are trying to get started. On my Mac, it was in /extras/google/google_play_services/samples
I have it in ~/Work/stack/
2) I copied the google-play-services_lib project directory to the same place (~/Work/stack), so my working directory looks like this. By the way, the lib project is located in /extras/google/google_play_services/libproject:
.
3) Now let’s open the Android studio. On the home screen, click Import Project and import our map project from ~/Work/stack/maps. We are currently receiving many complaints about unknown links to the GMS library:
4) We now need to add the Google Play service as a reference library. Go to View -> Open module parameters
5) In the Modules tab, click the + button and select Import a module and import the GooglePlayServices library. I didn’t change anything in the assistants, so I clicked through to the end:
6) You should now refer to this imported library. Open this screen again (go to Display -> Module settings). Make sure you have selected the map project and the Dependencies tab. Press + to add a dependency and select Library. Select your import library here:
7) We now see that he is not complaining about the GMS library, but about the supporting library:
8) Let’s solve this problem. My support library can be found at /extras/android/support/v13/android-support-v13.jar. So let’s try to add it to our workspace. Go to View -> Open Module Settings and select the Libraries tab. Select + -> Java and choose the support library :
9) You will now be asked which project you want to add this library to, so select your map project:
10) At this stage, the code should compile without any problems. Make sure you are pursuing the correct version of the SDK in the manifest.
loitering
Solution 2:
I followed the same instructions, except I created a new project. As part of the project structure, I removed the android gripper facet and was able to build successfully. Optionally, you can update the gradle build files and add Android gradle to the game services library.
NOTE: I changed the name of the Google Play Services directory.
build.gradle for the Google Play Services library.
Application plugin: android library
build {
repositories {
mavenCentral()
}
Dependencies {
classpath ‘com.android.tools.build:gradle:0.4’
}
}
Dependencies {
compile files (‘libs/android-support v4.jar’)
compile files (‘google-play-services.jar’)
}
android {
compileSdkVersion 17
buildToolsVersion ‘17.0.0
sourceSet {main {manifest.srcFile ‘AndroidManifest.xml’java.srcDirs = [‘src ]resources.srcDirs = [‘src ]aild.srcDirs = [‘src’]renderscript.srcDirs = [‘src’]res.srcDirs = [‘res’]assets.srcDirs = [‘assets’]]}}}}}
build.gradle for the test application.
build {
repositories {
maven { url ‘http://repo1.maven.org/maven2’ }
}
dependencies {
classpath ‘com.android.tools.build:gradle:0.4’
}
}
application plugin : android
Dependencies {
compile files(‘libs/android-support-v4.jar’)
compile project(‘:lib-google-play-services’)
compile files(‘…/lib-google-play-services/libs/google-play-services.jar’)
}
android {
compileSdkVersion 17
buildToolsVersion 17.0.0
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
}
Solution 3:
I’ve tried many tutorials on this topic and failed, but I finally found a simple solution that seems to work with Android Studio and gradle.
I just installed Android Studio 0.2.3 on my Mac, and these are the steps that led me to view the map snippets on the fresh hello world:
1) Click the SDK Manager button on the Android Studio toolbar.
2) Under Advanced, search and download Google Play services.
3) In your build.gradle file in the src directory, add this line to the :
Compile com.google.android.gms:play-services:3.1.36.
4) Order and install your API key by following these instructions: https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key
5) Paste the fragment into the xml layout :
6) You should now be able to run your project on the device.
Solution 4:
Here is the configuration of my project using the Google Maps V2 API, in Android Studio 0.2, with Degree 0.5.+. Other modules like ActiobarSherlock and the custom NumberPicker are also used, and I’ll leave them in case anyone needs them.
Structure of the project :
1) Catalog parameters TOP. deg :
include :SuperModule, :libraries:actionbarsherlock, :libraries:numberPicker.
2) Build.gradle top-level directory
Task Force
(Some of you may find that the task limit is not found. That is why you are setting this limit).
3) SuperModule build.gradle
build {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:0.5.+’
}
}
application plugin : android
Dependencies {
compile ‘com.google.android.gms:play-services:3.1.36’
compile ‘com.android.support:gridlayout-v7:13.0.0’
compile project (‘:libraries:actionbarsherlock’)
compile project (‘:libraries:numberPicker’)
}
android {
compileSdkVersion 17
buildToolsVersion 17.0.0
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
Note the outbuildings here. Its actiobarSherlock (ABS) and NumberPicker are used as Android libraries. I also use game services (so min sdk must be >=8), and the
support library is not included here as it is in the ABS library!
Actionbar Sherlock build.gradle :
build {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:0.5.+’
}
}
application plugin : android library
Dependencies {
compiles com.android.support:support:v4:13.0.0
}
android {
compileSdkVersion 17
buildToolsVersion 17.0.0
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSet {
main {
manifest.srcFile AndroidManifest.xml
java.srcDirs = [ src ]
resources.srcDirs = [ src ]
aidl.srcDirs = [‘src’]
renderscript.srcDirs = [‘src’]
res.srcDirs = [‘res’]
assets.srcDirs = [‘assets’]
]
instrumentTest.setRoot(testing)
}
}
NumberPicker build.gradle is not displayed because it uses the same logic as the other .
Solution no. 5:
I wrote an article and created a step-by-step mapping application using the location interface and the google map api. This goes through many silly situations I encountered when trying to start a mapping application, including activating the SDK, the libraries to import, the items to set in the Android manifest, and how to edit the ranking file.
I hope this helps.
Solution no. 6:
I had a similar problem, but it was that it couldn’t find the com.google.android.gms.maps package (it kept saying it didn’t exist). This was after I had (apparently) imported everything correctly, following the migration instructions in Google’s own documents: http://developer.android.com/sdk/installing/migrate.html.
Anyway, after importing everything, I still had a problem and I didn’t know how to define the build path (or its unobtrusive equivalent).
All I had to do was follow half of your tutorial below, remove the Google Play library that was already in the module settings window, and then reintegrate it.
I hope it’s helpful to someone else.
Solution no. 7:
I also had a similar problem, I decided to import google_play_services.jar as a library instead of google play services project as a module.
Good luck!
Related Tags:
google map configuration in android, maps sdk for android pricing, google maps api permissions, android map navigation example code, google maps api key permissions, google map configurations, google play-services-maps dependency, google maps android api v2” is enabled, google map android github, mapsactivity android, google location api for android, google map android example github, google map in fragment android example, getting location data in android, login google developer console, google map dependency, com.google.android.gms.maps.mapview example, google map android tutorial 2019, android api examples, how to refresh map fragment in android, tutorialspoint maps android, google maps embed api android, map android dev, google map dependency in android, mapview javatpoint, abhiandroid map, map type in android, google map journal dev, what is mapping in android, google map android interview questions, google map integration in android studio example, ensure that the “google maps android api v2” is enabled., how to use google map in android programmatically, how to use google api in android studio, android google map example androidhive, google map not showing in android studio, google map api, add google maps to existing android project