2

I've read all questions about the error (1,2,3,4,...) but non of them resolved my problem! I have the same error:

E/b: Authentication failed on the server.
E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
                       Ensure that the "Google Maps Android API v2" is enabled.
                       Ensure that the following Android Key exists:
                       API Key: XXXX
                       Android Application (<cert_fingerprint>;<package_name>): YYYY

I created a new app containing Google map sample by android studio wizard and also adding the google map in a simple project and everything was good! But in the main project that has 2 flavors and 3 modules (I wanted to add it to the app module), adding Google map faced the error above. Steps I followed:

  1. In the root package of the app (com.big.myapp) right click -> Google -> Google Maps Activity -> Finish
  2. Copy the url inside the google_maps_api.xml and open it in browser
  3. Create a new project and enable the API
  4. Copy the API Key and paste it in google_maps_api.xml
  5. Check manifest for ensure if <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key"/> is in it (that was)
  6. Run the app and open the MapActivity
  7. Face the ERROR
  8. Check SHA-1 and it was the same as is shown at the error!
  9. Uninstall and reinstall app
  10. Also moved the google_maps_api.xml to each flavor (and not worked)

My app build.gradle:

apply plugin: 'com.android.application'

android {
     compileSdkVersion rootProject.ext.compileSdkVersion
     buildToolsVersion rootProject.ext.buildToolsVersion
     defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
    release {
        minifyEnabled true
        useProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                output.outputFile = new File(
                        output.outputFile.parent,
                        output.outputFile.name.replace(".apk", "-${variant.versionCode}.apk")
                                .replace("app-release", "iOrder"))
            }
        }
    }
}
testOptions {
    unitTests.returnDefaultValues = true
}
productFlavors {
    iOrder {
        applicationId 'com.big.myapp'
        versionCode 41600
        versionName '4.16.0'
    }
    iForm {
        applicationId 'com.big.myapp2'
        versionCode 11600
        versionName '1.16.0'
    }
}
configurations {
    iMyDebugCompile
    iMyReleaseCompile
    iMy2DebugCompile
    iMy2ReleaseCompile
}
lintOptions {
    abortOnError false
}
}
   repositories {
       maven { url "https://jitpack.io" }
   }

dependencies {
    iMyDebugCompile project(path: ':gps-tracker', configuration: 'iMyDebug')
    iMyReleaseCompile project(path: ':gps-tracker', configuration: 'iMyRelease')
    iMy2DebugCompile project(path: ':gps-tracker', configuration: 'iMy2Debug')
    iMy2ReleaseCompile project(path: ':gps-tracker', configuration: 'iMy2Release')

compile fileTree(include: ['*.jar'], dir: 'libs')
/* Google */
testCompile "junit:junit:$rootProject.ext.junitVersion"
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion"
androidTestCompile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
androidTestCompile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:customtabs:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:support-annotations:$rootProject.ext.supportLibraryVersion"
/* play service */
//    compile 'com.google.android.gms:play-services-places:9.4.0'
/* third party */
compile project(path: ':gps-tracker')
compile project(path: ':changelog')
testCompile "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
testCompile "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"

// Android Testing Support Library's runner and rules
androidTestCompile "com.android.support.test:runner:$rootProject.ext.runnerVersion"
androidTestCompile "com.android.support.test:rules:$rootProject.ext.runnerVersion"

// Dependencies for Android unit tests
androidTestCompile "junit:junit:$rootProject.ext.junitVersion"
androidTestCompile "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"

// Espresso UI Testing
androidTestCompile "com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
androidTestCompile("com.android.support.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion")
androidTestCompile "com.android.support.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.commit451:PhotoView:1.2.4'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.google.code.gson:gson:2.7'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.alexbbb:uploadservice:1.6'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.2.1'
compile 'com.jakewharton.timber:timber:4.3.1'
compile 'pl.charmas.android:android-reactive-location:0.10@aar'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:appcompat-v7:22.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}
Community
  • 1
  • 1
AlizerA
  • 164
  • 2
  • 12

0 Answers0