Search code examples
androidgoogle-mapsandroid-studioandroid-mapviewandroid-maps

google map v1 is not showing afer change compileSdkVersion "Google Inc.:Google APIs:23"


top build.gradle is as:

// 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 is as:

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 is as:

<?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" />

before adding to compileSdkVersion "Google Inc.:Google APIs:23" google map is drawn in proper way. Because of as build it with Android Studio 2.1, it require to compileSdkVersion "Google Inc.:Google APIs:23" and after its not showing map.

Any one please suggest, what will i do for that to show google map


Solution

  • Google Maps v1 is deprecated, maybe that's why it's not working. It is stated here that:

    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.

    Although v1 will continue to work on device, no new features will be added to it and the support on it will not be entertained. Maybe that is also the reason why you cannot upgrade it to SDK Version 23. So I suggest you to update your code/project.

    For more information about the v1, check this link.