Skip to content Skip to sidebar Skip to footer

Error Executing The Build In The App (cordova Build Android), After Adding And Configuring "cordova-plugin-firebase"

I created an App using Cordova, then followed the instructions to prepare the App to integrate with the Firebase plugin: Created the keystore (needed to integrate with Firebase).

Solution 1:

I found a solution to problem:

Instructions similar to those I followed (and that caused the problem) are available here, although with the versions of the dependencies a bit outdated:

https://firebase.google.com/docs/android/setup

What caused the problem in my case was to follow these instructions on the App creation page in Firebase and add the dependencies in the build.gradle files of the project and module as can be seen below:

Add in project build.gradle /project/platforms/android/build.gradle:

buildscript {
    repositories {
        jcenter ()
        maven {
            url "https://maven.google.com"
        }
        Google()
    }
    dependencies {

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.1.3'

        // Firebase
        classpath 'com.google.gms: google-services: 4.0.0'
    }
}

And add in module build.gradle /project/platforms/android/app/build.gradle:

buildscript {
    repositories {
        mavenCentral ()
        jcenter ()
        maven {
            url "https://maven.google.com"
        }
        Google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

        // Firebase
        classpath 'com.google.gms: google-services: 4.0.0'
        classpath 'com.google.firebase: firebase-core: 16.0.0'
    }
}

// Firebase, add at the end of the same file
apply plugin: 'com.google.gms.google-services'

Answer :

The solution I found was to comment the lines that are preceded by the comment // Firebase:

File: /project/platforms/android/build.gradle:

buildscript {
    repositories {
        jcenter ()
        maven {
            url "https://maven.google.com"
        }
        Google()
    }
    dependencies {

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.1.3'

        // Firebase
        // classpath 'com.google.gms: google-services: 4.0.0'
    }
}

File: /project/platforms/android/app/build.gradle:

    buildscript {
        repositories {
            mavenCentral ()
            jcenter ()
            maven {
                url "https://maven.google.com"
            }
            Google()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'

            // Firebase
            //classpath 'com.google.gms: google-services: 4.0.0'
            //classpath 'com.google.firebase: firebase-core: 16.0.0'
        }
    }

// Firebase, add at the end of the same file
//apply plugin: 'com.google.gms.google-services'

After these steps, everything worked fine and I was able to run $ cordova build android without problems.


Suggestion: If any other errors occur, try removing the plugins and platform, then re-create them:

$ cordova plugin rm cordova-plugin-firebase$ cordova platform rm android
$ cordova plugin add cordova-plugin-firebase$ cordova platform add android

Post a Comment for "Error Executing The Build In The App (cordova Build Android), After Adding And Configuring "cordova-plugin-firebase""