关于本机依赖性问题的firebase



我目前正在尝试在React Native上实现Firebase Cloud Messaging Wormants(我想使用通知(。

但是,我遇到了与依赖关系有关的错误。

运行react-native run-android时,我会收到以下错误

D:wrkfldrHikingandroidappsrcmainjavacomhikingMainApplication.java:6: error: package io.invertase.firebase does not exist
import io.invertase.firebase.RNFirebasePackage;
                            ^
D:wrkfldrHikingandroidappsrcmainjavacomhikingMainApplication.java:29: error: cannot find symbol
            new RNFirebasePackage(),
                ^
  symbol: class RNFirebasePackage
2 errors
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception

这是我的app build.gradle

中的依赖项
dependencies {
    compile project(':react-native-fcm')
    compile 'com.google.firebase:firebase-messaging:11.6.0'
    compile "com.google.android.gms:play-services-base:11.6.0"
    compile "com.google.firebase:firebase-core:11.6.0"
    compile project(':react-native-cardview')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

这是mainapplication.java

package com.hiking;
import android.app.Application;
import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import com.kishanjvaghela.cardview.RNCardViewPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.evollu.react.fcm.FIRMessagingPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
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() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new RNFirebasePackage(),
            new FIRMessagingPackage(),
            new RNCardViewPackage()
      );
    }
    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };
  ...
}

我真的无法弄清楚问题在哪里。有人有什么想法吗?

尝试导入并使用rnfirebasemessagingpackage而是firmessagingpackage

...
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
...
new RNFirebaseMessagingPackage(),
...

还要确保您在packege.json文件中有反应 - fcm,如果不是制作

npm i react-native-fcm --save

相关内容

  • 没有找到相关文章

最新更新