Naivescript-Vue应用程序在初始化Firebase上崩溃:无法读取未定义的属性“ Android”

时间:2019-07-10 06:18:40

标签: firebase nativescript nativescript-vue

我正在尝试将Firebase Auth添加到我的nativescript vue项目中。 在安装插件并添加google-services.json(可能是这个文件吗?)之后,当我将初始化添加到main.js中时:

var firebase = require("nativescript-plugin-firebase");
firebase
  .init({
    // Optionally pass in properties for database, authentication and cloud messaging,
    // see their respective docs.
  })
  .then(
    function(instance) {
      console.log("firebase.init done");
    },
    function(error) {
      console.log("firebase.init error: " + error);
    }
  );

我收到以下错误:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 

Error calling module function 

TypeError: Cannot read property 'android' of undefined
File: "file:///data/data/org.boriswinner.teendok/files/app/vendor.js, line: 18175, column: 26

StackTrace: 
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 18175, column: 27
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 19085, column: 23
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase-common.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 14701, column: 13
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 15010, column: 25
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1447, column: 18
 Frame: function:'./main.js', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1464, column: 30
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'checkDeferredModules', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 45, column: 23
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 149, column: 18
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 152, column: 10
 Frame: function:'require', file:'', line: 1, column: 266


TypeError: Cannot read property 'android' of undefined
File: "<unknown>, line: 1, column: 265

StackTrace: 
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 18175, column: 27
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 19085, column: 23
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase-common.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 14701, column: 13
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 15010, column: 25
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1447, column: 18
 Frame: function:'./main.js', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1464, column: 30
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'checkDeferredModules', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 45, column: 23
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 149, column: 18
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 152, column: 10
 Frame: function:'require', file:'', line: 1, column: 266


 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5832)
 at android.app.ActivityThread.-wrap1(Unknown Source:0)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
 at android.os.Handler.dispatchMessage(Handler.java:106)
 at android.os.Looper.loop(Looper.java:173)
 at android.app.ActivityThread.main(ActivityThread.java:6653)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:821)
Caused by: com.tns.NativeScriptException: 

Error calling module function 

TypeError: Cannot read property 'android' of undefined
File: "file:///data/data/org.boriswinner.teendok/files/app/vendor.js, line: 18175, column: 26

StackTrace: 
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 18175, column: 27
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 19085, column: 23
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase-common.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 14701, column: 13
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 15010, column: 25
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1447, column: 18
 Frame: function:'./main.js', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1464, column: 30
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'checkDeferredModules', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 45, column: 23
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 149, column: 18
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 152, column: 10
 Frame: function:'require', file:'', line: 1, column: 266


TypeError: Cannot read property 'android' of undefined
File: "<unknown>, line: 1, column: 265

StackTrace: 
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 18175, column: 27
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/mlkit/index.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 19085, column: 23
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase-common.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 14701, column: 13
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'../node_modules/nativescript-plugin-firebase/firebase.js', file:'file:///data/data/org.boriswinner.teendok/files/app/vendor.js', line: 15010, column: 25
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1447, column: 18
 Frame: function:'./main.js', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 1464, column: 30
 Frame: function:'__webpack_require__', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 76, column: 30
 Frame: function:'checkDeferredModules', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 45, column: 23
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 149, column: 18
 Frame: function:'', file:'file:///data/data/org.boriswinner.teendok/files/app/bundle.js', line: 152, column: 10
 Frame: function:'require', file:'', line: 1, column: 266


 at com.tns.Runtime.runModule(Native Method)
 at com.tns.Runtime.runModule(Runtime.java:624)
 at com.tns.Runtime.run(Runtime.java:616)
 at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
 at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1120)
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5829)
 ... 8 more

怎么了?这是带有我的代码的仓库: https://github.com/boriswinner/teendok-ns/tree/auth

0 个答案:

没有答案