invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.68k stars 2.21k forks source link

🔥[🐛] Firebase Auth silently crash app during Phone Verification after adding SHA1 to firebase project #4490

Closed jeremycod closed 3 years ago

jeremycod commented 3 years ago

Issue

I'm using react-native-firebase app and auth in my application to verify users added real phone numbers and it's based on scenario described here https://heartbeat.fritz.ai/implement-firebase-phone-authentication-in-react-native-apps-237959027611 So far I was testing it using debug assemble and test phone numbers and it was working find. Now, I'm trying to prepare my application for release and I was trying to generated signed release and test phone verification. I did the following:

  1. generated release keystore and added it to android/app
  2. added these parameters to build.gradle android.signincConfigs.release storeFile file('my-release-key.keystore') storePassword 'my-password' keyAlias 'my-alias' keyPassword 'my-password' (basically following these steps https://medium.com/@raguct25/how-to-generate-signed-or-released-apk-file-from-react-native-252bdd1915a2)
  3. used keytool -list ... command to get SHA-1 and add it to Firebase console under my project.
  4. download new google-services.json and added it under android/app
  5. build release using any of these methods:
    • generate build using ./gradlew assembleRelease
    • generate signed APK using Android Studio
    • run release in simulator using react-native run-android —variant=release

In each of these builds when firebase is trying to authenticate it's causing app to crash when request to send OTP code is made if I try to use some actual phone number. It works well with test numbers. Same issue happens on actual device and simulator.

Debug version of the application which works fine for test phones when there was no SHA1 in firebase project is crashing both for real and test phone numbers now after SHA1 is added.

Code where error is happening is this:

            try {
                firebase
                    .auth()
                    .signInWithPhoneNumber(phone)
                    .then((confirmResult) => {
                        setConfirmResult(confirmResult);
                        setIsLoading(false);
                    })
                    .catch((error) => {
                        console.log(error)
                        setIsLoading(false);
                        setError(error.message);
                        setShowErrorAlert(true);               
                    })
            } catch(e) {
                throw e;
            }

None of this catch blocks is triggered. It just crash the whole app.


Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "FillRxMobile", "version": "1.0.0", "private": false, "scripts": { "start": "react-native start", "test": "jest", "test:update": "jest -u", "test:coverage": "jest --coverage", "run:ios": "react-native run-ios", "run:android": "react-native run-android", "lint": "./node_modules/eslint/bin/eslint.js src", "lint:fix": "./node_modules/eslint/bin/eslint.js src --fix", "flow": "./node_modules/flow-bin/cli.js", "e2e:build": "detox build --configuration ios.sim.debug", "e2e:test": "detox test --configuration ios.sim.debug", "postinstall": "npx jetify", "devtools": "react-devtools" }, "dependencies": { "@babel/polyfill": "^7.10.4", "@breeffy/react-native-popup-menu": "^0.8.0", "@react-native-community/blur": "^3.6.0", "@react-native-community/datetimepicker": "^3.0.4", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.9.3", "@react-native-community/picker": "^1.8.1", "@react-native-community/push-notification-ios": "^1.4.0", "@react-native-firebase/app": "^8.4.7", "@react-native-firebase/auth": "^9.3.2", "@react-navigation/bottom-tabs": "^5.5.2", "@react-navigation/drawer": "^5.8.2", "@react-navigation/native": "^5.5.1", "@react-navigation/stack": "^5.5.1", "axios": "^0.19.2", "d3-scale": "^3.2.1", "d3-shape": "^1.3.7", "date-fns": "^2.14.0", "gulp": "^4.0.2", "gulp-clean": "^0.4.0", "gulp-rename": "^2.0.0", "i18n-js": "^3.7.0", "immer": "^7.0.3", "jetifier": "^1.6.6", "jwt-decode": "^2.2.0", "libphonenumber-js": "^1.8.4", "lodash": "^4.17.19", "lottie-react-native": "^3.4.0", "moment": "^2.27.0", "react": "^16.11.0", "react-devtools": "^4.7.0", "react-loader-spinner": "^3.1.14", "react-native": "0.63.3", "react-native-animated-loader": "^0.0.8", "react-native-awesome-alerts": "^1.3.2", "react-native-calendars": "^1.299.0", "react-native-cli": "^2.0.1", "react-native-config": "^1.3.3", "react-native-dotenv": "^0.2.0", "react-native-dropdown-picker": "^3.1.11", "react-native-elements": "^2.3.2", "react-native-gesture-handler": "^1.6.1", "react-native-gifted-chat": "^0.16.1", "react-native-image-picker": "^2.3.1", "react-native-keyboard-aware-scroll-view": "^0.9.3", "react-native-lightbox": "^0.8.0", "react-native-linear-gradient": "^2.5.6", "react-native-localize": "^1.3.1", "react-native-maps": "^0.27.1", "react-native-material-dropdown": "git+https://github.com/noway/react-native-material-dropdown.git", "react-native-menu-button": "^1.0.0", "react-native-modal": "^11.5.6", "react-native-modal-datetime-picker": "^9.0.0", "react-native-modal-selector": "^2.0.2", "react-native-nav": "^2.0.2", "react-native-phone-call": "^1.0.9", "react-native-picker-select": "^7.0.0", "react-native-push-notification": "^4.0.0", "react-native-reanimated": "^1.9.0", "react-native-render-html": "^4.2.0", "react-native-safe-area-context": "^3.0.5", "react-native-screens": "^2.9.0", "react-native-snap-carousel": "^3.9.1", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^12.1.0", "react-native-svg-charts": "^5.4.0", "react-native-ui-lib": "^5.9.3", "react-native-vector-icons": "^7.0.0", "react-native-webview": "^10.9.0", "react-redux": "^7.2.0", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", "react-uuid": "^1.0.2", "recompose": "^0.30.0", "redux": "^4.0.1", "redux-logger": "^3.0.6", "redux-persist": "^6.0.0", "redux-saga": "^1.1.3", "redux-thunk": "^2.3.0", "socket.io": "^2.3.0", "socket.io-client": "^2.3.0", "use-state-with-callback": "^1.0.18", "victory-native": "^34.3.0" }, "devDependencies": { "@babel/cli": "^7.10.5", "@babel/core": "^7.11.1", "@babel/preset-env": "^7.11.0", "@react-native-community/async-storage": "^1.11.0", "babel-eslint": "^10.0.1", "babel-jest": "^26.0.1", "danger": "^10.2.0", "enzyme": "^3.7.0", "enzyme-adapter-react-16": "^1.7.0", "eslint": "^7.3.0", "eslint-config-airbnb": "^18.2.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-react": "^7.20.0", "flow-bin": "^0.127.0", "jest": "^26.4.2", "metro-react-native-babel-preset": "^0.61.0", "react-dom": "^16.6.3" }, "jest": { "preset": "react-native", "transform": { "^.+\\.js$": "/node_modules/react-native/jest/preprocessor.js" }, "collectCoverage": true, "collectCoverageFrom": [ "src/**/*.{js,jsx}", "!**/node_modules/**", "!android/**", "!ios/**", "!assets/**" ], "coverageDirectory": "jest_coverage", "setupFiles": [ "./jest-setup.js" ], "testPathIgnorePatterns": [ "/node_modules/", "/e2e/" ] }, "rnpm": { "assets": [ "./assets/fonts/" ] }, "detox": { "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/FillRxApp.app", "build": "xcodebuild -UseModernBuildSystem=NO -project ios/FillRxApp.xcodeproj -scheme FillRxApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", "type": "ios.simulator", "name": "iPhone XS" }, "ios.sim.release": { "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/FillRxApp.app", "build": "xcodebuild -UseModernBuildSystem=NO -project ios/FillRxApp.xcodeproj -scheme FillRxApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build", "type": "ios.simulator", "name": "iPhone 7" } }, "test-runner": "jest" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. ext { buildToolsVersion = "29.0.3" minSdkVersion = 16 compileSdkVersion = 29 targetSdkVersion = 28 supportLibVersion = "27.1.1" } buildscript { ext { buildToolsVersion = "29.0.3" minSdkVersion = 16 compileSdkVersion = 29 targetSdkVersion = 29 supportLibVersion = "27.1.1" } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.5.2") classpath 'com.google.gms:google-services:4.3.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } mavenLocal() google() jcenter() } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "rootSaga.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ enableHermes: true, ] apply from: "../../node_modules/react-native/react.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", true); android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) { storeFile file(MYAPP_RELEASE_STORE_FILE) storePassword MYAPP_RELEASE_STORE_PASSWORD keyAlias MYAPP_RELEASE_KEY_ALIAS keyPassword MYAPP_RELEASE_KEY_PASSWORD } } } defaultConfig { applicationId "com.fillrxapp" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 2 versionName "2.1" multiDexEnabled true } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://facebook.github.io/react-native/docs/signed-apk-android. //signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" signingConfig signingConfigs.release } } packagingOptions { pickFirst "lib/armeabi-v7a/libc++_shared.so" pickFirst "lib/arm64-v8a/libc++_shared.so" pickFirst "lib/x86/libc++_shared.so" pickFirst "lib/x86_64/libc++_shared.so" } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { def multidex_version = "2.0.1" implementation "androidx.multidex:multidex:$multidex_version" implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation platform('com.google.firebase:firebase-bom:26.0.0') implementation 'com.google.firebase:firebase-auth' implementation 'com.google.firebase:firebase-analytics' debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } compile project(':react-native-vector-icons') } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'FillRxApp' include ':react-native-webview' project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android') include ':react-native-push-notification' project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':react-native-splash-screen' project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android') include ':@react-native-community_datetimepicker' project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android') include ':react-native-image-picker' project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' ``` #### `MainApplication.java`: ```java package com.fillrxapp; import android.app.Application; import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.reactnativecommunity.webview.RNCWebViewPackage; import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage; import com.oblador.vectoricons.VectorIconsPackage; import org.devio.rn.splashscreen.SplashScreenReactPackage; import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage; import com.facebook.react.ReactInstanceManager; import com.imagepicker.ImagePickerPackage; import com.horcrux.svg.SvgPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.reactcommunity.rnlocalize.RNLocalizePackage; import com.BV.LinearGradient.LinearGradientPackage; import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage; import java.lang.reflect.InvocationTargetException; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); return packages; } @Override protected String getJSMainModuleName() { return "index"; } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } /** * Loads Flipper in React Native templates. Call this in the onCreate method with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper( Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class aClass = Class.forName("com.fillrxapp.ReactNativeFlipper"); aClass .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 10.15.7 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 76.26 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.2.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.1, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0 System Images: android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-R | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6514223 Xcode: 12.1/12A7403 - /usr/bin/xcodebuild Languages: Java: 11.0.7 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: ^16.11.0 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [] Android - [ ] **iOS** but have not tested behavior on Android - [x ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`


mikehardy commented 3 years ago

It seemed you had a second comment about the DeviceCheck API step missing, and that it should obviously not crash - it should throw an exception or similar. If there is something we can add to the docs, there is a link top-right of each page for a quick edit + PR, and similarly if you caught a stack trace on the native crash in your testing, and know where the exception might be a caught, a PR would be greatly appreciated :pray:

jeremycod commented 3 years ago

Hi @mikehardy I wrote a comment that enabling DeviceCheck API solved an issue, but later I've realized I'm still having the same issue with Android emulator and I still don't know why it's crashing, so I've deleted the comment until I figure out what is the problem. I believe this is just the configuration issue, but I have no experience with firebase and react-native-firebase, so without exception indicating what is the problem, I find it difficult to figure out what's the problem.

mikehardy commented 3 years ago

what's the stack when watching with adb logcat - that usually points to the issue, it's how I figure out crashes on Android

jeremycod commented 3 years ago

Hi @mikehardy Thanks for advice. I was not aware of adb logcat. That now makes more sense. This is the exception I got in Android emulator:

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

There is some similar issue discussed here https://stackoverflow.com/questions/64608484/firebase-phone-verification-verifyphonenumber-deprecated-application-crashed though, I'm not using verifyPhoneNumber but:

firebase
       .auth()
       .signInWithPhoneNumber(phone)
mikehardy commented 3 years ago

Yeah, when they do a reCAPTCHA verification on phones it uses an internal web page which uses custom tabs

If you add the dependency mentioned to your project it will likely work: https://developers.google.com/web/android/custom-tabs/implementation-guide

However I think it should work anyway - if auth uses browser internally it should depend on it, but when I check the android dependency tree via cd android && ./gradlew :app:dependencies I see that auth does not bring browser dependency in but other of the firebase modules do, that's likely why I've never seen this.

If you verify that including the browser dependency fixes the bug, then you could likely file an upstream bug with firebase-android-sdk indicating that this file should contain the transitive dependency, like this one does https://github.com/firebase/firebase-android-sdk/blob/a9a6b9c1de64f49f691b18fe402590ec982f6bd5/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle#L81

Unfortunately auth is not open sourced (I don't think?) so I can't reference the actual gradle file for it

mikehardy commented 3 years ago

I don't find a relevant upstream issue, FWIW https://github.com/firebase/firebase-android-sdk/issues?q=is%3Aissue+NoClassDefFoundError+customtabs

jeremycod commented 3 years ago

You're right. This was the problem and adding

 implementation "androidx.browser:browser:1.2.0"

into app/build.gradle dependencies solved issue.

Thanks a lot for your help.

mikehardy commented 3 years ago

Excellent! @jeremycod Would you mind opening an issue with firebase-android-sdk ? Normally they require a non-react-native-firebase reproduction but in this case I think a simple check by them of their auth dependencies in their closed source auth gradle file should show the problem, in combination with a reference to this issue

Ashwani10101 commented 3 years ago

Yeah, when they do a reCAPTCHA verification on phones it uses an internal web page which uses custom tabs

If you add the dependency mentioned to your project it will likely work: https://developers.google.com/web/android/custom-tabs/implementation-guide

However I think it should work anyway - if auth uses browser internally it should depend on it, but when I check the android dependency tree via cd android && ./gradlew :app:dependencies I see that auth does not bring browser dependency in but other of the firebase modules do, that's likely why I've never seen this.

If you verify that including the browser dependency fixes the bug, then you could likely file an upstream bug with firebase-android-sdk indicating that this file should contain the transitive dependency, like this one does https://github.com/firebase/firebase-android-sdk/blob/a9a6b9c1de64f49f691b18fe402590ec982f6bd5/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle#L81

Unfortunately auth is not open sourced (I don't think?) so I can't reference the actual gradle file for it

Thanks it worked u saved me

ghost commented 3 years ago

Yeah, when they do a reCAPTCHA verification on phones it uses an internal web page which uses custom tabs

If you add the dependency mentioned to your project it will likely work: https://developers.google.com/web/android/custom-tabs/implementation-guide

However I think it should work anyway - if auth uses browser internally it should depend on it, but when I check the android dependency tree via cd android && ./gradlew :app:dependencies I see that auth does not bring browser dependency in but other of the firebase modules do, that's likely why I've never seen this.

If you verify that including the browser dependency fixes the bug, then you could likely file an upstream bug with firebase-android-sdk indicating that this file should contain the transitive dependency, like this one does https://github.com/firebase/firebase-android-sdk/blob/a9a6b9c1de64f49f691b18fe402590ec982f6bd5/firebase-inappmessaging-display/firebase-inappmessaging-display.gradle#L81

Unfortunately auth is not open sourced (I don't think?) so I can't reference the actual gradle file for it

Live Saver advice !

thomashagstrom commented 3 years ago

Lifesaver indeed. How is this closed without the fix being documented?

mikehardy commented 3 years ago

@thomashagstrom how have you not updated to the current version where it is fixed with no documentation needed :smile: https://github.com/invertase/react-native-firebase/blob/master/CHANGELOG.md#1060-2021-02-04

We're working hard over here as a community and me personally fixing these things and releasing them. If you ever crash with react-native-firebase see if you are up to date, and if you are not, check the changelog, you might have a fix for the thing you crashed on.

misfityudi commented 1 year ago

You're right. This was the problem and adding

 implementation "androidx.browser:browser:1.2.0"

into app/build.gradle dependencies solved issue.

Thanks a lot for your help.

This doesn't work either. Been a week now : (