[英]Nativescript app keeps crashing on android after adding firebase plugin
我的 nativescript 應用程序運行良好,直到我添加了 firebase 插件。 現在,當我在我的設備上運行它時,它給出了錯誤消息“應用程序已停止工作”。 請幫忙
這是我正在使用的插件https://github.com/EddyVerbruggen/nativescript-plugin-firebase
在 Windows 系統上為 android 構建時,我發現問題出在插件上。 在 macbook 上構建時不會發生這種情況。 我已經在他們的 github 存儲庫上記錄了投訴,其他一些人和我有同樣的問題。 那里有一些答案,您可以查看它們
google-services.json 應該在 app/App_Resources/Android 你使用 tns run 之類的嗎? 如果是這樣,終端的整個錯誤是什么? 應用程序停止工作聽起來不像是一個完整的輸出。
就我而言,我的應用程序 (nativescript vue) 在成功復制 google-services.json 后崩潰,但在渲染應用程序時崩潰。 我通過在 App 級 build.gradle (//build.gradle) 文件中添加所有必需的依賴項來解決它,如下所示:
apply plugin: 'com.android.application'
// Add this line
apply plugin: 'com.google.gms.google-services'
dependencies {
// add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.2.2'
// add SDKs for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
通過參考上面 SDK 鏈接中列出的 Gradle 依賴項,確保根據您啟用的 Firebase 功能添加所有必需的依賴項。 請記住,Analytics 還需要包含其他幾個依賴項。 添加所有必需的依賴項后,我的應用程序啟動時沒有崩潰。
還要確保在項目級 build.gradle (/build.gradle) 文件中:
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}
我希望這可以幫助任何面臨類似問題的人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.