cannot resolve symbol 'android' on android studio

怎甘沉沦 提交于 2019-12-06 07:32:55

It is recommended to use the new Maps v2 API.

To use it, add the following dependency to your build.gradle:

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

And then follow Google's guide to set it up. You can find it here

Edit: To elaborate more on the build.gradle file, here is what mine looks like.

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '20'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'

        applicationId '<package_name>'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            debuggable true
            runProguard false
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.android.support:support-annotations:+'
    compile 'com.google.android.gms:play-services:5.0.77'
}

Important Note: There is two build.gradle files in every project. Put this in the one that is inside the corresponding module folder. The module is often called app, if you haven't renamed it.

After adding it make sure you click on the Sync Project with Gradle Files button on the top, so it will download the required dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!