从 Nativescript firebase 插件初始化 firabase.init() 时出错

Error while initializing firabase.init() from Nativescript firebase plugin

我正在尝试使用 原生脚本 firebase 插件 FCM 以实现 推送通知 在我的 本机脚本 应用程序中。但是当我试图根据文档调用 firebase init 来启动 firebase 时。

  firebase.init({
        onMessageReceivedCallback: function(message) {
            console.log("Title: " + message.title);
            console.log("Body: " + message.body);
            // if your server passed a custom property called 'foo', then do this:
            console.log("Value of 'foo': " + message.data.foo);
        }
    }).then(function (instance) {
        console.log("firebase.init done");
    }, function (error) {
        console.log("firebase.init error: " + error);
    });

我遇到了这个错误

Error in firebase.init: Error: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:275)
com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:231)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
com.tns.Runtime.callJSMethod(Runtime.java:957)
com.tns.Runtime.callJSMethod(Runtime.java:941)
com.tns.Runtime.callJSMethod(Runtime.java:933)
com.tns.gen.android.view.GestureDetector_SimpleOnGestureListener_frnal_ts_helpers_l58_c38__TapAndDoubleTapGestureListenerImpl.onSingleTapUp(GestureDetector_SimpleOnGestureListener_frnal_ts_helpers_l58_c38__TapAndDoubleTapGestureListenerImpl.java:12)
android.view.GestureDetector.onTouchEvent(GestureDetector.java:635)
android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480)
android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
com.tns.Runtime.callJSMethod(Runtime.java:957)
com.tns.Runtime.callJSMethod(Runtime.java:941)
com.tns.Runtime.callJSMethod(Runtime.java:933)

但是在安装插件的过程中,我只设置了cloud messagingAndroidplatform。我没有使用火力认证。对于 facebook 登录,我使用 native-script-OAuth 插件。

这是来自nativescript-plugin-firebase/platform/android

include.gradle
android {
   productFlavors {
     "fireb" {
        dimension "fireb"
      }
  }
}

repositories {
   jcenter()
    mavenCentral()
    maven {
       url "https://maven.google.com"
   }
}

def supportVersion = project.hasProperty("supportVersion") ? project.supportVersion : "26.0.0"

dependencies {
    compile "com.android.support:appcompat-v7:$supportVersion"
    compile "com.android.support:cardview-v7:$supportVersion"
    compile "com.android.support:customtabs:$supportVersion"
    compile "com.android.support:design:$supportVersion"
    compile "com.android.support:support-compat:$supportVersion"

     def firebaseVersion = "12.0.1"

    // make sure you have these versions by updating your local Android SDK's (Android Support repo and Google repo)
  compile "com.google.firebase:firebase-core:$firebaseVersion"
  compile "com.google.firebase:firebase-auth:$firebaseVersion"

  // for reading google-services.json and configuration
   def googlePlayServicesVersion = 
    project.hasProperty('googlePlayServicesVersion') ? 
    project.googlePlayServicesVersion : firebaseVersion
    compile "com.google.android.gms:play-services-
   base:$googlePlayServicesVersion"

   // Uncomment if you want to use the regular Database
  // compile "com.google.firebase:firebase-database:$firebaseVersion"

  // Uncomment if you want to use 'Cloud Firestore'
  // compile "com.google.firebase:firebase-firestore:$firebaseVersion"

  // Uncomment if you want to use 'Remote Config'
  // compile "com.google.firebase:firebase-config:$firebaseVersion"

  // Uncomment if you want to use 'Crash Reporting'
  // compile "com.google.firebase:firebase-crash:$firebaseVersion"

  // Uncomment if you want FCM (Firebase Cloud Messaging)
 compile "com.google.firebase:firebase-messaging:$firebaseVersion"

  // Uncomment if you want Google Cloud Storage
  // compile "com.google.firebase:firebase-storage:$firebaseVersion"

  // Uncomment if you want AdMob
  // compile "com.google.firebase:firebase-ads:$firebaseVersion"

  // Uncomment if you need Facebook Authentication
  // compile ("com.facebook.android:facebook-android-sdk:4.+"){ exclude group: 'com.google.zxing' }

  // Uncomment if you need Google Sign-In Authentication
  // compile "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"

  // Uncomment if you need Firebase Invites or Dynamic Links
  // compile "com.google.firebase:firebase-invites:$firebaseVersion"
}
apply plugin: "com.google.gms.google-services"

如果有人能帮助我,那就太好了。

ok,这个问题是因为native-script facebook 插件。我之前还安装了 native-script-facebook 插件,导致了这个问题。可能是插件冲突什么的。卸载native-script facebook后,现在已经解决了。