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

后端 未结 7 1527
暗喜
暗喜 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:56

    Here is a configuration for a project I made that uses Google Maps API V2, in Android Studio 0.2, with gradle 0.5.+. Also other modules like ActiobarSherlock, and a custom NumberPicker are used, and i just leave them in case someone needs them.

    Project structure:

    enter image description here

    1) TOP Directory settings.gradle:

    include ':SuperModule', ':libraries:actionbarsherlock', ':libraries:numberPicker'
    

    2) TOP Directory build.gradle

    task assemble {}
    

    (some of you may faces the task assemble not found. thats why you put this line!)

    3) SuperModule build.gradle

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.5.+'
        }
    }
    apply 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
        }
    }
    

    Notice the dependencies here. Its actiobarSherlock(ABS), and NumberPicker, used as android Libraries. I also use Play Services(thats why the min sdk must be >=8), and the layout lib (for the space element) Support library is NOT included here, since its included in ABS library!

    Actionbar Sherlock build.gradle:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.5.+'
        }
    }
    apply plugin: 'android-library'
    
    dependencies {
        compile 'com.android.support:support-v4:13.0.0'
    }
    
    android {
        compileSdkVersion 17
        buildToolsVersion "17.0.0"
    
        defaultConfig {
            minSdkVersion 7
            targetSdkVersion 16
        }
        sourceSets {
            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('tests')
        }
    }
    

    NumberPicker build.gradle isnt shown because it has the same logic with the others..

    0 讨论(0)
提交回复
热议问题