androidgoogle-playrelease-builds

Cannot connect to internet in release build apk


I've created an Android application. I tested it in debug mode and works completely fine. But when I tried to release build the apk, it's not connecting to the internet at all. I used Google sign in and firebase.

AndroidManifest.xml

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.REAL_GET_TASKS " />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    ....

build.gradle

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

android {
    compileSdkVersion 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        applicationId "com.defenderstudio.geeksjob"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 1
        versionName '1.0'
        multiDexEnabled true


        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildFeatures {
        viewBinding true
    }
}
...

Solution

  • If you were you not able to login using Google sign in, you have to put your Release SHA1 (from Google play or firbase console and your apk generated) key in google firebase console and then download and replace Json File and you'll be able to login.