Error creating Google Maps Activity

Asked

Viewed 163 times

0

When I create in my project a new -> Google -> Google Maps Activity he creates everything correctly.


Then add the key to google_maps_api.xml.

inserir a descrição da imagem aqui

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">
    chave . . .
</string>

However, when I compile the project presents the following error:

Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.Processexception: org.gradle.process.internal.Execexception: Process 'command 'C: Program Files (x86) Java jdk1.8.0_65 bin java.exe'' finished with non-zero Exit value 2 Information:BUILD FAILED Information:Total time: 37.338 secs Information:1 error Information:0 warnings Information:See complete output in console


It automatically puts it in the dependencies (Compile 'com.google.android.gms:play-services:9.4.0')

If I switch to version 8.4.0 (Compile 'com.google.android.gms:play-services:8.4.0') it stops giving the error but when I enter the map’s Activity, it does not appear. only the google logo appears at the bottom left corner of the screen.

  • 1

    Can’t add the full stack trace?

  • Whoa, I updated the question

1 answer

1


Cristian,

Take a look at your Androidmanifest.xml

You’ll notice there at the end that’s like this:

<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_maps_key" />

You need to register this KEY there in the Dashboard in Google, you will need the SHA-1 of your development machine.

Give a search on how to generate KEY HASH for Google Maps.

I hope I helped, Hugs.

  • The key I added. The strange thing is that when I create direct from Android Studio, automatically it adds dependency (Compile 'com.google.android.gms:play-services:9.4.0') but if I put with version 8.4.0 (Compile 'com.google.android.gms:play-services:8.4.0') it does not present the error however when I enter the map does not appear, only the logo on google at the bottom right of the screen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.