FirebaseUI-Android icon indicating copy to clipboard operation
FirebaseUI-Android copied to clipboard

Adding Hilt to FirebaseUI minimal project causes AuthMethodPickerActivity to not launch

Open mikezank opened this issue 3 years ago • 3 comments

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?

  • For issues or feature requests related to the code in this repository file a GitHub issue.
  • For general technical questions, post a question on StackOverflow tagged appropriately.
  • For general Firebase discussion, use the firebase-talk google group
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel

Step 2: Describe your environment

  • Android device: _Emulator
  • Android OS version: API32_
  • Google Play Services version: 4.3.14_
  • Firebase/Play Services SDK version: _____
  • FirebaseUI version: 8.0.2

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:

  • What happened? This could be a description, logcat output, etc.

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:

  • What did you expect to happen? Successful display of FirebaseUI AuthMethodPickerActivity

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

mikezank avatar Oct 13 '22 18:10 mikezank

Firebase requires appcompat dependency, you should add

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

murgupluoglu avatar Mar 08 '23 15:03 murgupluoglu

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 avatar Oct 30 '23 14:10 Yadi80580539

What this mean

Yadi80580539 avatar Oct 30 '23 14:10 Yadi80580539