I am trying to login using Google Sign In API. It works while I was debugging it. Once I generate the release APK to upload on play store the sign in method is showing some error called caused by:

java.lang.ClassNotFoundException:com.google.android.gms.auth.api.signin.internal.SignInConfiguration

class MainActivity : AppCompatActivity() {

    lateinit var mGoogleSignInClient : GoogleSignInClient
    lateinit var googleSignOption : GoogleSignInOptions
    val Unique_Code : Int = 1
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)



        googleSignOption = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build()
        mGoogleSignInClient = GoogleSignIn.getClient(this , googleSignOption)


        button_gmail_registration.setOnClickListener {
            signInWithGoogle()
            progressbar_gmail_registration_screen.visibility = View.VISIBLE
            button_gmail_registration.visibility = View.INVISIBLE
        }
    }
    private fun signInWithGoogle(){
        val signInIntent : Intent = mGoogleSignInClient.signInIntent
        startActivityForResult(signInIntent , Unique_Code)

    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        Log.d("GmailRegistration","On Activity result")
            if (requestCode == Unique_Code){
            val task : GoogleSignInResult = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
            handleResult(task)
        }
    }

    private fun  handleResult(taskCompleted: GoogleSignInResult){
        try {
             val account  = taskCompleted.signInAccount(ApiException::class.java)
            Log.d("GmailRegistration","handle Result")
            Log.d("GmailRegistration", "$account")
           progressbar_gmail_registration_screen.visibility = View.INVISIBLE
              val intent = Intent(this, HomeActivity::class.java)
             startActivity(intent)
            finish()

        }catch (e : ApiException){
            progressbar_gmail_registration_screen.visibility = View.INVISIBLE
            Log.d("GmailRegistration","$e")
            Toast.makeText(this, "$e",Toast.LENGTH_LONG).show()
            button_gmail_registration.visibility = View.VISIBLE
        }

    }
}

And the build app module is

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.errorfoundteam.gmaillogintest"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'

0 Answers