3

I am struggling with google sign in with android app. I followed steps from given link Google Sign-In for Android I have created google-services.json file with same application-ID/Package Name which is in AndroidMenifest.xml file. Please quick check into below AndroidMenifest.xml code along with google-services.json file.

AndroidMenifest.xml

<?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="demo.abc.com.deals">
        <uses-sdk tools:overrideLibrary="com.facebook" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission  android:name="android.permission.ACCESS_NETWORK_STATE"  />
        <application
        android:name=".ParityApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
        <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            />
        <activity
            android:name=".views.splash.SplashActivity"
            android:configChanges="keyboard|orientation|screenSize"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:configChanges="keyboard|orientation|screenSize"
            android:exported="false"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden|adjustPan" />

    </application>

</manifest>

google-services.json

"client_info": {
    "mobilesdk_app_id": "1:216768689126:android:64277ad0e8ef7db8",
    "android_client_info": {
      "package_name": "demo.abc.com.deals"
    }

build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "demo.abc.com.deals"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dataBinding {
    enabled true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
    mavenCentral()
}
buildTypes {
    debug {
        debuggable true
        applicationIdSuffix '.debug'
        buildConfigField("String", "SCHEME", "\"http:\"")
        buildConfigField("String", "AUTHORITY", "\"//139.162.46.29\"")
        buildConfigField("String", "SERVER_URL", "\"http://139.162.46.29/v3\"")
        resValue 'string', 'app_name', 'Parity-SIT'
    }
    uat.initWith(buildTypes.debug)
    uat {
        applicationIdSuffix '.uat'
        buildConfigField("String", "SCHEME", "\"http:\"")
        buildConfigField("String", "AUTHORITY", "\"//139.162.46.29\"")
        buildConfigField("String", "SERVER_URL", "\"http://139.162.46.29/v3\"")
        resValue 'string', 'app_name', 'Parity-UAT'
    }
    release {
        minifyEnabled false
        resValue 'string', 'app_name', 'Parity'
        buildConfigField("String", "SCHEME", "\"http:\"")
        buildConfigField("String", "AUTHORITY", "\"//139.162.46.29\"")
        buildConfigField("String", "SERVER_URL", "\"http://139.162.46.29/v3\"")
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-annotations:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.18.0'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'me.tatarka.retrolambda'

Project level build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'me.tatarka:gradle-retrolambda:3.6.0'
    classpath 'com.google.gms:google-services:3.0.0'

}

In all three files package name is demo.abc.com.deals but still I am getting this error as.

Error:Execution failed for task ':app:processDebugGoogleServices'. No matching client found for package name 'demo.abc.com.deals.debug'.

I tried each and every suggestions on same issue raised here on SO but not even single solution work for me. I could really use all SO users suggestions and experiences to deal with this issue.

google-services.json file adding dir structure

google-service.json file added under app dir.

Sandeep Devhare
  • 440
  • 1
  • 6
  • 16

2 Answers2

16

Finally, I fixed this problem while integrating google sign in to my app, As I am trying to get setup for google sign in for my app,I have added 3 build variants in app level build.gradle file.

It works fine when I added google-services.json for each build type, there should be accordant director in app/src folder. Please check below screen shot of dir structure after adding google-services.json file in respective build variants folder.

Application dir structure after changes

Mendatory changes

In all google-services.json files you should specify correct package_name according to build types.

Such as, inside debug dir it should be like "package_name": "demo.abc.com.deals.debug"

Sandeep Devhare
  • 440
  • 1
  • 6
  • 16
0

Add below code in bottom of your gradle

apply plugin: 'com.google.gms.google-services'

like this

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.1'
    compile 'com.google.android.gms:play-services-auth:11.0.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'


}
apply plugin: 'com.google.gms.google-services'
Anil
  • 1,605
  • 1
  • 14
  • 24