How can I create an Android application in Android Studio that uses the Google Maps Api v2?

后端 未结 7 1572
暗喜
暗喜 2020-11-27 10:01

I\'ve been having a lot of trouble in Android Studio trying to create an app with GoogleMap.

I have followed the following guide before with (almost) no issues usin

7条回答
  •  借酒劲吻你
    2020-11-27 10:54

    I was following the same instructions except I was creating a new project. Under the project structure I removed the Android-Gradle facet and was able to build successfully. Optionally one can update the gradle build files and add the Android-Gradle facet to the play services library.

    NOTE: I changed the name of Google Play Services directory.

    build.gradle for Google Play Services library.

    apply plugin: 'android-library'
    
    buildscript {
        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'
    
        sourceSets {
            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 test app.

    buildscript {
        repositories {
            maven { url 'http://repo1.maven.org/maven2' }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.4'
        }
    }
    apply 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
        }
    }
    

提交回复
热议问题