Hi everyone.
Getting this when attempting to reset password with sendPasswordResetEmail. Happens only on Android. Being googling for 2 days now, so feels like I should ask here. react-native-firebase 6.
All the other auth features work as expected which is incredibly strange.
5222 3102 E unknown:ReactNative: Exception in native call
5222 3102 E unknown:ReactNative: com.facebook.react.bridge.NoSuchKeyException: url
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getNullableValue(ReadableNativeMap.java:122)
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getNullableValue(ReadableNativeMap.java:126)
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getString(ReadableNativeMap.java:161)
5222 3102 E unknown:ReactNative: at io.invertase.firebase.auth.ReactNativeFirebaseAuthModule.buildActionCodeSettings(ReactNativeFirebaseAuthModule.java:1915)
5222 3102 E unknown:ReactNative: at io.invertase.firebase.auth.ReactNativeFirebaseAuthModule.sendPasswordResetEmail(ReactNativeFirebaseAuthModule.java:444)
5222 3102 E unknown:ReactNative: at java.lang.reflect.Method.invoke(Native Method)
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371)
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:150)
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
5222 3102 E unknown:ReactNative: at android.os.Handler.handleCallback(Handler.java:873)
5222 3102 E unknown:ReactNative: at android.os.Handler.dispatchMessage(Handler.java:99)
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26)
5222 3102 E unknown:ReactNative: at android.os.Looper.loop(Looper.java:193)
5222 3102 E unknown:ReactNative: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:225)
5222 3102 E unknown:ReactNative: at java.lang.Thread.run(Thread.java:764)
Click To Expand
#### JS:
import firebase from '@react-native-firebase/app'
import '@react-native-firebase/auth'
...
resetPasswordByEmail = async (email: string) => {
firebase.crashlytics().setUserEmail(email)
try {
// crash happens after calling this
await firebase.auth().sendPasswordResetEmail(email)
return { success: true }
} catch (err) {
return { success: false, error: err.message }
}
}
#### `package.json`:
"@react-native-firebase/app": "^6.3.2",
"@react-native-firebase/auth": "^6.3.2",
"@react-native-firebase/crashlytics": "^6.3.2",
...
"firebase": "^7.8.1",
...
"react": "^16.12.0",
"react-dom": "^16.11.0",
"react-native": "^0.61.5",
### Android
#### `android/build.gradle`:
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.1")
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
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")
}
maven { url 'https://jitpack.io' }
}
}
project.ext {
excludeAppGlideModule = true
}
#### `android/app/build.gradle`:
apply plugin: "com.android.application"
apply plugin: "io.fabric"
crashlytics {
enableNdk true
}
import com.android.build.OutputFile
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.someapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 43
versionName "0.18.5"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
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 {
implementation project(':react-native-video')
implementation project(':react-native-screens')
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// 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 plugin: 'com.google.gms.google-services'
#### `android/settings.gradle`:
rootProject.name = 'someproject'
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'```
#### `MainApplication.java`:
```java
package com.someapp;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.brentvatne.react.ReactVideoPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
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<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> 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); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
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.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
#### `AndroidManifest.xml`:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.someapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
android:largeHeap="true"
>
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan"
android:exported="true"/>
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> -->
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
</application>
</manifest>
Click To Expand
react-native info output:System:
OS: macOS 10.15.3
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 64.20 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.11.1 - /usr/local/bin/node
Yarn: 1.19.0 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: ^16.12.0 => 16.12.0
react-native: ^0.61.5 => 0.61.5
npmGlobalPackages:
react-native-cli: 2.0.1
Could you edit this line in your node modules https://github.com/invertase/react-native-firebase/blob/master/packages/auth/lib/index.js#L234:
- sendPasswordResetEmail(email, actionCodeSettings = {}) {
+ sendPasswordResetEmail(email, actionCodeSettings) {
return this.native.sendPasswordResetEmail(email, actionCodeSettings);
}
If that works, please let me know :)
In Anroid and iOS the actionCodeSettings are optional they are ignored if null:
https://github.com/invertase/react-native-firebase/blob/master/packages/auth/ios/RNFBAuth/RNFBAuthModule.m#L628
https://github.com/invertase/react-native-firebase/blob/master/packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java#L439
But in fact in javascript they are initialized by default to an empty object: https://github.com/invertase/react-native-firebase/blob/master/packages/auth/lib/index.js#L234
Yeah @Ehesp just came to the same solution I was heading for and beat me to it :-)
@Ehesp this helps, as well as providing null to sendPasswordResetEmail as a second param.
@mikehardy
Is this thing documented?
Thank you guys.
It's an issue on our end really, we'll get it updated.
Reopened since it's a WIP bug now (looks like).
Hi @auseika, I've finally merged in this PR (#3192) which ought to fix this issue by passing null as a default instead of an empty object. Thanks for raising the issue 馃憤
Thanks for fixing this one @russellwheatley !
Most helpful comment
Hi @auseika, I've finally merged in this PR (#3192) which ought to fix this issue by passing
nullas a default instead of an empty object. Thanks for raising the issue 馃憤