谷歌地图v1没有显示更改更改compileSdkVersion"谷歌公司:谷歌API:23"

时间:2016-09-13 07:47:31

标签: android google-maps android-studio android-mapview android-maps

top build.gradle如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    apply from: 'versions.gradle'

    repositories {
        jcenter()
    }
    dependencies {
        // Update checkable at https://jcenter.bintray.com/com/android/tools/build/gradle/
        classpath 'com.android.tools.build:gradle:2.1.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle如下:

apply plugin: 'com.android.application'

android {
    //compileSdkVersion "$rootProject.compileSdkVersion"
    buildToolsVersion "$rootProject.buildToolsVersion"
//    compileSdkVersion 23
    compileSdkVersion "Google Inc.:Google APIs:23"


    defaultConfig {
        applicationId "nl.sogeti.android.gpstracker"
        testApplicationId "nl.sogeti.android.gpstracker.tests"
        minSdkVersion 15
        targetSdkVersion 15
        versionCode 1540
        versionName "1.5.4"
        buildConfigField "int", "BUILD_NUMBER", System.getenv("BUILD_NUMBER") as String ?: "0"
        buildConfigField "String", "GIT_COMMIT", "\"" + System.getenv("GIT_COMMIT") + "\"" as String ?: "\"Unknown\""
        generatedDensities = ["hdpi", "xxhdpi"]
        archivesBaseName = "opengpstracker-$versionName"
    }

    if (rootProject.file("keystore.properties").exists()) {
        apply from: 'signing.gradle'
    }

    buildTypes {
        debug {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
    compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:preference-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:design:$rootProject.supportLibraryVersion"
    compile "com.android.support:support-annotations:$rootProject.supportLibraryVersion"
    compile "com.jakewharton.timber:timber:$rootProject.timberVersion"
//    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.google.android.gms:play-services-base:7.3.0'
    compile 'com.google.android.gms:play-services-location:7.3.0'

    compile 'com.google.maps:google-maps-services:0.1.3'
//    compile 'com.android.support:appcompat-v7:23.1.0'
    compile project(':service')
    testCompile "junit:junit:$rootProject.junitVersion"

}

map.xml如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mapScreen"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <!--android:apiKey="0bmdf4-ggC50QWBY1OgGRutQ9bIboIy11OczZbw" -->
    <com.google.android.maps.MapView
        android:id="@+id/myMapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/support_actionbar"
        android:apiKey="0bmdf4-ggC50QWBY1OgGRutQ9bIboIy11OczZbw"
        android:clickable="true"
        android:enabled="true"
        android:visibility="visible" />

    <TextView
        android:id="@+id/currentSpeed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/support_actionbar"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:textColor="#ff000000"
        android:textSize="12pt"
        android:textStyle="bold"
        android:visibility="gone" />

在添加到compileSdkVersion&#34; Google Inc.:Google API之前:23&#34;谷歌地图以适当的方式绘制。由于使用Android Studio 2.1进行构建,因此需要编译SDdVersion&#34; Google Inc.:Google API:23&#34;并且在没有显示地图之后。

任何人请建议,我将如何为此显示谷歌地图

1 个答案:

答案 0 :(得分:1)

谷歌地图v1已被弃用,也许这就是它无法正常工作的原因。 here表示:

  

注意:Google Maps Android API版本1已正式发布   截至2012年12月3日已弃用。这意味着从3月18日起,   2013年,您将无法再为此请求API密钥   版。 Google Maps Android API v1不会添加任何新功能。   但是,使用v1的应用程序将继续在设备上运行。现有和   我们鼓励新开发者使用Google Maps Android API v2。

虽然v1将继续在设备上运行,但不会添加任何新功能,并且不会对其提供支持。也许这也是你无法将其升级到SDK Version 23的原因。所以我建议你更新你的代码/项目。

有关v1的详细信息,请查看此link