1

my nativescript app was working fine until i added firebase plugin. Now, when i run it on my device, it gives the error message 'app has stopped working' . Please help

this is the plugin i'm using https://github.com/EddyVerbruggen/nativescript-plugin-firebase

kunlee
  • 591
  • 1
  • 4
  • 15
  • Have you added google-services.json file? – Dhruv Feb 01 '20 at 11:22
  • yes, i have. but just to be clear must it be in the same folder as my AndroidManifest.xml. Cause the docs said i should put it here `C:\Users\user\tabs\app\App_Resources\Android\google-services.json` but my androidmanifest is here `C:\Users\user\tabs\app\App_Resources\Android\src\` – kunlee Feb 01 '20 at 11:33
  • What services you are using from Firebase? Did you make sure all services you use are enabled in `firebase.nativescript.json`? Did you try a clean build? Have you written any code that accesses the plugin APIs upon launch / init methods? – Manoj Feb 01 '20 at 16:10
  • yes, in its doc, it said i should add fiebase.init to my app.js, i did that. i'm going to try your other solutions too @Manoj – kunlee Feb 02 '20 at 08:37

3 Answers3

1

I found out the issue was with the plugin when building for android on windows system. it doesn't occur when building on a macbook. i already logged a complaint on their github repository, some other people have the same issue as me. there are some answers there, you can check them out

kunlee
  • 591
  • 1
  • 4
  • 15
0

The google-services.json should be in app/App_Resources/Android Are you using tns run or suchlike? If so what is the whole error from the terminal? App stopped working doesn't sound like a complete output.

Patrick
  • 39
  • 4
0

In my case my app (nativescript vue) was crashing after successfully copying the google-services.json, but at the time of rendering the app. I resolved it by adding all required dependencies in App-level build.gradle (//build.gradle) file as shown below:

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 

Make sure to add all required dependencies based on the Firebase features you have enabled by referring to the Gradle dependency listed in the SDK link above. Keep in mind that Analytics requires several other dependencies to be included as well. After adding all required dependencies, my app started without crasing.

Also make sure that in Project-level build.gradle (/build.gradle) file:

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    
    ...    
  }    
}

I hope this helps anyone facing similar issue.