'Running gradle build is failed When try to run on device?

before that i have uninstalled visual studio code , android studio and gradle , my project was running on device fine , but when reinstalled tools and try command :

ionic cap run android --livereload --consolelogs --serverlogs --external

to build and run my project on my device , I m facing this error :

Build file 'E:\Mes Projets\Mobile\iStore\iStore\node_modules\@capacitor-community\fcm\android\build.gradle' line: 29
[capacitor]
[capacitor]         * What went wrong:
[capacitor]         A problem occurred evaluating project ':capacitor-community-fcm'.
[capacitor]         > initialize must be called for meta class of class build_asct3wckhlowifz9k3uacapmo$_run_closure2$_closure6(class org.codehaus.groovy.runtime.metaclass.ClosureMetaClass) to complete initialisation process before any invocation or field/property access can be done 

my build.gradle file :

    ext {
    junitVersion =  project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
    androidxJunitVersion =  project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
    androidxEspressoCoreVersion =  project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
    firebaseMessagingVersion =  project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '21.0.1'
}

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
    defaultConfig {
        minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
        targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
    }

    compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    google()
    jcenter()
    mavenCentral()
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':capacitor-android')
    testImplementation "junit:junit:$junitVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
    androidTestImplementation 'com.android.support:support-annotations:28.0.0'
    implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion"
    implementation 'com.android.support:appcompat-v7:28.0.0'
}

Note : im using Fcm for firebase messaging

how can i solve this error , any help ? 

thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source