RNFirebase未在Android上加载

时间:2017-11-29 09:01:46

标签: react-native react-native-firebase

我想使用firebase手机身份验证,所以我想尝试添加react-native-firebase ... 我把它添加到android / app / build.gradle

    dependencies {
    compile project(':react-native-config')
    compile(project(':react-native-firebase')) {
        transitive = false
    }

    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules

    // Firebase dependencies
    compile "com.google.android.gms:play-services-base:11.6.0"
    compile "com.google.firebase:firebase-core:11.6.0"
    compile "com.google.firebase:firebase-auth:11.6.0"
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'

项目级别 build.gradle

 buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.1'
        classpath 'com.android.tools.build:gradle:2.2.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com'
        }

    }
}

我也做了反应原生的链接 但它没有加载..

你能帮我找到我在这里错过的东西......

enter image description here

2 个答案:

答案 0 :(得分:1)

其迟到的回复但对其他人有帮助。 您需要在getPackages中的MainApplication.java文件中添加RNFirebasePackage包。

 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() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new RNFirebasePackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

Helpful Answer

答案 1 :(得分:0)

我的问题是我试图将React-native-firebase与EXPO一起使用,这是不可能的。