-1

I'm trying to get Google Maps working in my signed release build. It doesn't display any grid lines or tiles, it's just blank with my UI shown on top. The map loads perfectly with the debug build.

Android studio monitor (logcat) also stopped working when I used a new phone(4.4.2 vs 4.4.4), so I can't filter information.

  • I've restarted my computer
  • I've added the API key to AndroidManifest.xml
  • I've tried creating new key/keystores 3 times
  • I've updated the SHA1/package name in the Google Developer console (console.developers.google.com) each time
  • I've tried Regenerating the API key in the console once

(when I removed the debug credentials from the console only the cached maps would load, so I know the console is responsive)

build.gradle (Project)

    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
    }
allprojects {
    repositories {
        jcenter()
    }
}

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

gradle.build(app)

     apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    signingConfigs {
        release {
            storeFile new File(project.projectDir, 'mykeystore.keystore')
            storePassword 'pass'
            keyAlias 'mykey'
            keyPassword 'pass'
        }
    }
    defaultConfig {
        applicationId "apps.baconcheesegames.com.real_timesocialrunnerfinder"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.google.android.gms:play-services-ads:8.1.0'
    compile 'com.google.android.gms:play-services-identity:8.1.0'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
}

Suspicious message: LocationConsent failed, ULR opt-in status is: false

Blank map when running release build

baconcheese113
  • 843
  • 2
  • 13
  • 27
  • 1
    Please post your `build.gradle` as its likely a signing or package name issue. Also what does `logcat` say when it tries to load? – JBirdVegas Oct 21 '15 at 01:03
  • Ok, I posted it. Android studio logcat no longer outputs any message since I started using the new phone. I had worked earlier the same day with the other phone. – baconcheese113 Oct 21 '15 at 01:16
  • @JBirdVegas The package name in build.gradle matches the package name in the console – baconcheese113 Oct 21 '15 at 02:37

4 Answers4

1

This is google map key issue. So enable google map api for android .For refedrence use this and mention following meta tag in manifest file

 <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="key" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
Rahul Chaudhary
  • 1,059
  • 1
  • 6
  • 15
  • let me know if face any problem – Rahul Chaudhary Oct 21 '15 at 05:38
  • ?:??: W/?(?): Caused by: android.view.InflateException: Binary XML file I got this error: java.lang.RuntimeException: The API key can only be specified once. It is recommended that you use the meta-data tag with the name: com.google.android.geo.API_KEY in the element of AndroidManifest.xml – baconcheese113 Oct 21 '15 at 18:15
  • I replaced "geo.API_KEY" with "maps.v2.API_KEY" and nothing changed. Map is still blank. – baconcheese113 Oct 21 '15 at 18:23
  • I'm able to build the apk and send to a friend by selecting "Debug" instead of "Release" while Generating an Apk. This doesn't solve why my Release build doesn't work though. – baconcheese113 Oct 23 '15 at 20:43
1

You need to explicitly set the keystore for both debug and release builds. Then you need to ensure the google apis are expecting the SHA-1 fingerprint for that keystore.

signingConfigs {
    release {
        storeFile new File(project.projectDir, 'my_key.keystore')
        storePassword 'myKeystorePassword'
        keyAlias 'myAlias'
        keyPassword 'myPassword'
    }
}

defaultConfig {
}

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
    debug {
        signingConfig signingConfigs.release
    }
}
JBirdVegas
  • 10,855
  • 2
  • 44
  • 50
  • Should this be in the build.gradle (project) or build.gradle(app) ? – baconcheese113 Oct 21 '15 at 18:23
  • @baconcheese113, This would be in your `app/build.gradle` – JBirdVegas Oct 21 '15 at 18:45
  • Ok, I tried adding it. It is still blank for my release build. Also, the debug build still loads new maps with this configuration. See above build.gradle file – baconcheese113 Oct 21 '15 at 18:53
  • Then you need to check your keystore `SHA-1` hash and package name is correct in Google Developer console. – JBirdVegas Oct 22 '15 at 15:49
  • They are correct and i've tried replacing them with new key/keystore/SHA1 combinations several times. I did get an unrelated error saying SDK_HOME was missing or something a while back. – baconcheese113 Oct 22 '15 at 18:36
  • I got it working on my friend's phone by selecting debug instead of release with "Generate Signed APK". I'm not sure how this will effect me later on though. – baconcheese113 Oct 22 '15 at 22:53
1

All of the answers were legitimate, however my issue was due to not putting the API key in the release google_maps_api.xml file. Just in the debug file.

Maybe you have two google_maps_api.xml files, one in the app/src/debug/res/values folder and the other in the app/src/release/res/values folder, but only the debug one contains your API key.

https://stackoverflow.com/a/32170277/1363772

Community
  • 1
  • 1
baconcheese113
  • 843
  • 2
  • 13
  • 27
0

Debug SHA-1 certificate fingerprint will be different from production(signed) SHA-1 certificate fingerprint , so you need to set both debug SHA-1 fingerprint and production(signed) keystore SHA-1 fingerprint for same package.

To get Keystore SHA-1 fingerprint you can use following command

keytool -list -v -keystore mystore.keystore 

go to location of your keystore from terminal and replace mystore.keystore with your generated keystore. And set the production(signed) keystore SHA-1 fingerprint for same package in google developer console

Yatish
  • 521
  • 3
  • 14