Ionic firebase specify google-services.json

前端 未结 1 1234
孤独总比滥情好
孤独总比滥情好 2021-01-07 11:17

I have an ionic 3 project and I wanted to add firebase to the project.

I installed the firebase cordova plugin and placed my google-services.json in resources/

相关标签:
1条回答
  • 2021-01-07 12:13

    Try this steps.

    1. first remove your android platform to your project using ionic cordova platform remove android

    2. copy google-services.json file to the root directory (where package.json/config.xml file).

    3. then try to add android platoform using ionic cordova platform add android.then check your android folder google-services.json file copied automatically,if not then copy it to the android folder.

    4. Then check your build.gradle fileto include the google-services plugin and the Google's Maven repository:

      buildscript{
         //add dependencies as per your google-service version
       dependencies {
           classpath 'com.google.gms:google-services:4.2.0' // google-services plugin 
       }
      
       allprojects {
         repositories {
             google() // Google's Maven repository
       }
      }
      
    5. Then, in your module Gradle file (app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin

      dependencies {
          implementation 'com.google.firebase:firebase-core:16.0.7'
       }
      
      // ADD THIS AT THE BOTTOM
      apply plugin: 'com.google.gms.google-services'
      

    Note:If you are using codova-android >= 7, you now must add

     <platform name="android">
         <resource-file src="google-services.json" target="app/google-services.json" />
     </platform>
    
    0 讨论(0)
提交回复
热议问题