firebase-android-sdk: SignInWithPhoneNumber fails on emulator due to missing browser dependency

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • 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.

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

I know this is not place to report react-native-firebase, but it seems that the problem is cause by the bug in firebase-android-sdk and could be easily fixed.

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

Relevant Code:

firebase
                    .auth()
                    .signInWithPhoneNumber(phone)

This code caused app to crash in Android emulator with the following exception:

11-09 10:36:31.681   303  8778 W android.hardware.audio.service.ranchu: TinyalsaSink::write:125 pcm_write was late reading frames, dropping 22131 us of audio
11-09 10:36:31.703   303  8778 W android.hardware.audio.service.ranchu: TinyalsaSink::write:125 pcm_write was late reading frames, dropping 22131 us of audio
11-09 10:36:31.704 26370 26370 D AndroidRuntime: Shutting down VM
11-09 10:36:31.705 26370 26370 E AndroidRuntime: FATAL EXCEPTION: main
11-09 10:36:31.705 26370 26370 E AndroidRuntime: Process: com.fillrxapp, PID: 26370
11-09 10:36:31.705 26370 26370 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at android.os.AsyncTask.finish(AsyncTask.java:771)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at android.os.AsyncTask.access$900(AsyncTask.java:199)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:223)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7656)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/~~6eWSD3gCIvYqPb-GrDJ-Kg==/com.fillrxapp-gbh8cuZ6n2cKCKIKV-hi1g==/base.apk"],nativeLibraryDirectories=[/data/app/~~6eWSD3gCIvYqPb-GrDJ-Kg==/com.fillrxapp-gbh8cuZ6n2cKCKIKV-hi1g==/lib/x86, /data/app/~~6eWSD3gCIvYqPb-GrDJ-Kg==/com.fillrxapp-gbh8cuZ6n2cKCKIKV-hi1g==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
11-09 10:36:31.705 26370 26370 E AndroidRuntime: 	... 12 more
11-09 10:36:31.710   520 26549 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
11-09 10:36:31.710   520  1833 W ActivityTaskManager:   Force finishing activity com.fillrxapp/com.google.firebase.auth.internal.RecaptchaActivity
11-09 10:36:31.712   317  1866 D goldfish-address-space: allocate: Ask for block of size 0x5da800

It seems that auth in this case doesn’t add browser which is used for reCAPTCH verification and thus it’s causing crash on Android.

Adding

implementation "androidx.browser:browser:1.2.0"

to app/build.gradle solved the issue.

Relevant discussion could be found here https://github.com/invertase/react-native-firebase/issues/4490

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 34 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I don’t know why google-oss-bot is closing it again and again. This issue is even reproduceable in Unity3D with firebase_unity_sdk_7.0.2 for .NET 4. Stack trace is exactly the same and adding implementation ‘androidx.browser:browser:1.3.0’ fixed it. @malcolmdeck @mikehardy

I was loathe to add a dependency that I couldn’t understand the need for (given that I can write apps that only rely on Auth, don’t include this dep, and don’t crash), but you’re right - it’s causing problems, and adding this dep fixes it, so I have. It’ll come out in the next release that Auth is a part of.

@malcolmdeck I feel like I’m just being punked at this point 🤣

@malcolmdeck very happy to hear this! I think it’s easy to understand though - auth uses reCAPTCHA on android in certain cases, and reCAPTCHA requires APIs provided by androidx.browser - q.e.d. auth is already factually dependent on androidx.browser and needs to express that in it’s dependencies list

Sorry, I think the bot works by examining labels and dates and I forgot to remove needs-info. Anyways, I’m taking a look

This is my app/build.gradle file. The bug occurs in a Nokia 3.1 Plus running Android 10, plus the latest Flutter version.

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "..."
        minSdkVersion 18
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:26.1.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-auth'
    // implementation "androidx.browser:browser:1.2.0"
}

This is the stack trace:

E/AndroidRuntime( 8224): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime( 8224): 	at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.1:13)
E/AndroidRuntime( 8224): 	at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth@@20.0.1:7)
E/AndroidRuntime( 8224): 	at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(Unknown Source:2)
E/AndroidRuntime( 8224): 	at android.os.AsyncTask.finish(AsyncTask.java:755)
E/AndroidRuntime( 8224): 	at android.os.AsyncTask.access$900(AsyncTask.java:192)
E/AndroidRuntime( 8224): 	at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
E/AndroidRuntime( 8224): 	at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 8224): 	at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 8224): 	at android.app.ActivityThread.main(ActivityThread.java:7386)
E/AndroidRuntime( 8224): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8224): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 8224): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)

And indeed the problem goes away by adding the dependency: implementation "androidx.browser:browser:1.2.0"

This problem occurs in 26.1.0 too.