google 更改 compileSdkVersion 后地图 v1 未显示 "Google Inc.:Google APIs:23"
google map v1 is not showing afer change compileSdkVersion "Google Inc.:Google APIs:23"
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 之前 "Google Inc.:Google APIs:23" google 地图以正确的方式绘制。由于使用 Android Studio 2.1 构建它,因此需要编译 SdkVersion "Google Inc.:Google APIs:23" 并且在它不显示地图后。
任何人请建议,我将如何显示 google 地图
Google Maps v1 已弃用,也许这就是它无法正常工作的原因。据称here:
Note: Version 1 of the Google Maps Android API has been officially
deprecated as of December 3rd, 2012. This means that from March 18th,
2013 you will no longer be able to request an API key for this
version. No new features will be added to Google Maps Android API v1.
However, apps using v1 will continue to work on devices. Existing and
new developers are encouraged to use Google Maps Android API v2.
尽管 v1 将继续在设备上运行,但不会添加任何新功能,也不会接受对它的支持。也许这也是您无法将其升级到 SDK 版本 23 的原因。所以我建议您更新您的 code/project。
有关 v1 的更多信息,请查看此 link。
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 之前 "Google Inc.:Google APIs:23" google 地图以正确的方式绘制。由于使用 Android Studio 2.1 构建它,因此需要编译 SdkVersion "Google Inc.:Google APIs:23" 并且在它不显示地图后。
任何人请建议,我将如何显示 google 地图
Google Maps v1 已弃用,也许这就是它无法正常工作的原因。据称here:
Note: Version 1 of the Google Maps Android API has been officially deprecated as of December 3rd, 2012. This means that from March 18th, 2013 you will no longer be able to request an API key for this version. No new features will be added to Google Maps Android API v1. However, apps using v1 will continue to work on devices. Existing and new developers are encouraged to use Google Maps Android API v2.
尽管 v1 将继续在设备上运行,但不会添加任何新功能,也不会接受对它的支持。也许这也是您无法将其升级到 SDK 版本 23 的原因。所以我建议您更新您的 code/project。
有关 v1 的更多信息,请查看此 link。