firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.61k stars 1.83k forks source link

Adding Hilt to FirebaseUI minimal project causes AuthMethodPickerActivity to not launch #2068

Open mikezank opened 1 year ago

mikezank commented 1 year ago

Welcome to FirebaseUI and thanks for submitting an issue!

Please take a look at open issues, as well as resolved issues, to see if your issue is either already being addressed, or has been solved by someone else.

If not, please feel free to fill in the following info so we can help faster!

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

Adding Hilt to the project causes AuthMethodPickerActivity to fail to launch with this error: "You need to use a Theme.AppCompat theme (or descendant) with this activity."

Steps to reproduce:

  1. _Created smallest example using Compose + MainActivity launching FirebaseUI Activity that works OK
  2. __Added Hilt libraries and the app crashes

Observed Results:

Process: io.zsoft.firebaseuiminimum, PID: 31152 java.lang.RuntimeException: Unable to start activity ComponentInfo{io.zsoft.firebaseuiminimum/com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3685)

Expected Results:

Relevant Code:

  // TODO(you): code here to reproduce the problem

val signInLauncher = rememberLauncherForActivityResult(contract = FirebaseAuthUIActivityResultContract()) {
        val response = it.idpResponse
        Log.e("signInLauncher", "response = ${response.toString()}")
        if (it.resultCode == Activity.RESULT_OK) {
            Log.e("signInLauncher", "signed in OK")
        } else {
            Log.e("signInLauncher", "sign in error = ${response?.error}")
        }
    }
    Button(modifier = Modifier.wrapContentSize(), onClick = {
        val providers = arrayListOf(
            AuthUI.IdpConfig.EmailBuilder().build(),
            AuthUI.IdpConfig.PhoneBuilder().build(),
            AuthUI.IdpConfig.GoogleBuilder().build(),
        )
        val signInIntent = AuthUI.getInstance()
            .createSignInIntentBuilder()
            .setIsSmartLockEnabled(false)
            .setAvailableProviders(providers)
            .build()
        signInLauncher.launch(signInIntent)
    }) {
        Text("Authenticate")
    }

The above code works fine without Hilt in the project. Adding just one dependency (implementation "com.google.dagger:hilt-android:2.44") somehow crashes the App

murgupluoglu commented 1 year ago

Firebase requires appcompat dependency, you should add

implementation("androidx.appcompat:appcompat:1.6.1")

Yadi80580539 commented 8 months ago

t.ContextWrapper.sendBroadcast:468 com.oneplus.coreservice.Broadca stDispatch.xne$mab.onReceive:122 android.app.LoadedApk$Receiver D ispatcher$Args.lambda$getRunna ble$O$LoadedApk$ReceiverDispa tcher$Args:1566 android.app.-$ $Lambda$LoadedApk$ReceiverDispa tcher$Args$_BumDX2UKsnxLVrE6UJs JZkatuA.run:2 10-30 06:53:15.571 D/

Yadi80580539 commented 8 months ago

What this mean