【问题标题】:You attempted to use a fire base module that's not installed on your android project by calling firebase.analytics()您试图通过调用 firebase.analytics() 来使用未安装在您的 android 项目上的 fire 基础模块
【发布时间】:2019-11-22 11:37:12
【问题描述】:

我已将 firebase 安装到我的 react 本机应用程序中,我将需要 firebase 分析模块。

app/build.gradle:

    implementation 'com.google.firebase:firebase-core:17.2.1'
    implementation "com.google.android.gms:play-services-gcm:16.0.0"
    implementation "com.google.firebase:firebase-messaging:20.0.1"
    implementation "com.google.firebase:firebase-analytics:17.2.1"

MainActivity.java

private FirebaseAnalytics mFirebaseAnalytics;

@Override
protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this, R.style.SplashScreenTheme);  // here
    super.onCreate(savedInstanceState);

    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
}

反应原生

import firebase from "react-native-firebase";
firebase.analytics().logEvent("your_custom_event", {"custom_parm": "cp_value"});

但我在 android studio 的 logcat 控制台上收到此错误:

E/ReactNativeJS:错误:您试图通过调用 firebase.analytics() 来使用未安装在您的 Android 项目上的 firebase 模块。

确保您有:

1) 在您的“android/app/build.gradle”文件中安装了所需的 Firebase Android SDK 依赖项“com.google.firebase:firebase-analytics”。

2) 在“MainApplication.java”文件中导入“io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage”模块。

3) 在 RN 'getPackages()' 方法列表中添加了 'new RNFirebaseAnalyticsPackage()' 行。

有关完整设置说明,请参阅 http://invertase.link/android

在反应原生控制台中我看到:

D8:程序类型已经存在:android.support.v4.app.INotificationSideChannel$Stub$Proxy

【问题讨论】:

    标签: android react-native firebase-analytics react-native-firebase


    【解决方案1】:

    解决方案: 我使用了错误的版本:

        implementation 'com.google.firebase:firebase-core:16.0.8'
        implementation "com.google.firebase:firebase-messaging:17.5.0"
        implementation "com.google.firebase:firebase-analytics:16.4.0"
    

    【讨论】:

      【解决方案2】:
      => mainAppliction.java
      
      add these line
      
      import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; // <-- Add this line
      
      and add package
      
      packages.add(new RNFirebaseMessagingPackage());
      
      
        implementation project(':clevertap-react-native')
        implementation 'com.clevertap.android:clevertap-android-sdk:3.6.0'
        implementation 'com.android.support:multidex:1.0.3'
      
        implementation "com.google.firebase:firebase-messaging:18.0.0"
        // This should be here already
        implementation project(':react-native-firebase')
      
        // Firebase dependencies
        implementation "com.google.android.gms:play-services-base:16.1.0"
        implementation "com.google.firebase:firebase-core:16.0.9"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-01-06
        • 1970-01-01
        • 2021-05-27
        • 2020-01-20
        • 2020-12-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多