0

I have two Android Studio projects using Google Maps. One works fine, the other is unable to find com.google.android and so can't compile. Fails with

error: package com.google.android.gms.maps.model does not exist

Both have the same code in Manifest.xml

<meta-data android:name="com.google.android.gms.version" android:value="4323000" />

Both have the same import statement.

build.gradle is:

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.0.3"

defaultConfig {
    minSdkVersion 11
    targetSdkVersion 19
}

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:appcompat-v7:+'
}

I've read several similar questions on StackOverflow but those answers have no beneficial effect.

Any thoughts appreciated ...

Andrew
  • 1,222
  • 1
  • 10
  • 14
  • Make sure that you use the Google API – penkzhou May 11 '14 at 04:55
  • Please post your build.gradle – Pieces May 11 '14 at 05:08
  • 1
    Did you add Google Play services ???? – Lal May 11 '14 at 07:22
  • 1
    See this [link](http://stackoverflow.com/questions/21081598/import-google-play-services-library-in-android-studio) too.. – Lal May 11 '14 at 07:24
  • @Lal thanks for the suggestion. Google Play Services Rev 16 was added via SDK Manager, but it seems you have to manually add it via Project/Structure as a Dependency also. (I didn't do that on the project that was working already, but it does show up there, so somehow it added automatically in that case) Anyway, after manual addition it now works. Thanks for your help. – Andrew May 11 '14 at 14:09
  • Hi @Andrew.. Happy that you got it right..:) I have added that as my answer..Can you please mark my answer as accepted..If you can please upvote my answer too.. – Lal May 11 '14 at 15:25
  • @Lal I've upticked your comments above, but don't see your answer or acceptance of the question yet – Andrew May 12 '14 at 00:21
  • Hi @Andrew.. I've added it as my answer.. – Lal May 12 '14 at 05:10

2 Answers2

0

Please add Google Play services to your project..

Google Play Services Rev 16 was added via SDK Manager, but it seems you have to manually add it via Project/Structure as a Dependency also. (You didn't do that on the project that was working already, but it does show up there, so somehow it added automatically in that case) So kindly add that manually..

Lal
  • 14,726
  • 4
  • 45
  • 70
0

Add this to dependencies:

compile 'com.google.android.gms:play-services:4.3.23'

And replace (or leave) 4.3.23 with version you need, i.e. 4.3.+

Prizoff
  • 4,486
  • 4
  • 41
  • 69