如何将Nativescript安装到Sidekick nativescript应用中而不会出现错误?

时间:2019-04-25 13:31:25

标签: firebase firebase-cloud-messaging nativescript

简介

嗨,这是我第一个使用Nativescript的应用程序,我对应用程序开发以及Angulair或Vue不熟悉。所以我用JavaScript来开发它。

我使用Sidekick来启动和构建我的应用程序。我在Android Play商店中启动了测试版,目前,我正尝试将Firebase连接到我的应用。

Firebase插件安装(EddyVerbruggen)

我直接通过sidekick或通过命令行安装了插件 tns plugin add nativescript-plugin-firebase

规范

同伴踢
*版本:1.16.2-v.2019.3.13.12
* NativeScript CLI版本:5.3.0
* CLI扩展nativescript-cloud版本:1.17.3
* CLI扩展nativescript-starter-kits版本:0.3.5

tns文件
*组件tns-core-modules具有5.3.1版本,并且是最新的。
*组件tns-android具有5.3.1版本,并且是最新的。
*组件tns-ios具有5.3.1版本,并且是最新的。

代码

在app / app.js中

const application = require("tns-core-modules/application");

const firebase = require("nativescript-plugin-firebase");

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

application.run({ moduleName: "app-root" });

一旦我需要nativescript-plugin-firebase,应用就会崩溃。

文件在/ node_modules / nativescript-plugin-firebase中很好

    Firebase中的
  • google-services.json位于app / App_Resources / Android /

错误

错误:com.tns.NativeScriptException:无法找到模块:“ nativescript-plugin-firebase”,相对于:app / tns_modules /

编辑

我将“ nativescript-plugin-firebase”目录和文件复制到platform \ android \ app \ src \ main \ assets \ app \ tns_modules,但仍然失败。

3 个答案:

答案 0 :(得分:2)

您需要先安装nativescript-plugin-firebase插件,然后才能在应用程序中使用它。有关安装软件包的更多信息,请参见Sidekick documentation。从CLI as well可以实现相同的目的。

答案 1 :(得分:0)

实际上,缺少一些依赖(adj关键字)

答案 2 :(得分:0)

从{N} 5.3开始执行const firebase = require("tns-core-modules/nativescript-plugin-firebase");,您需要声明绝对路径

相关问题