Failed to apply plugin [id 'com.github.dcendents.android-maven']

Hello there. I couldn’t solve the problem. When I create a new project and give the command “cordova run android”, I get the same error. I mean, if it’s doing it in a new project, why?
Thanks for your answer.

cordova run android

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\Meftun\AppData\Local\Android\sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app

> Configure project :CordovaLibProject evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Meftun\Desktop\helloWorld2\platforms\android\CordovaLib\build.gradle' line: 41

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> Failed to apply plugin [id 'com.github.dcendents.android-maven']
   > Configuration with name 'testImplementation' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s

C:\Users\Meftun\Desktop\helloWorld2\platforms\android\gradlew: Command failed with exit code 1 Error output:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Meftun\Desktop\helloWorld2\platforms\android\CordovaLib\build.gradle' line: 41

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> Failed to apply plugin [id 'com.github.dcendents.android-maven']
   > Configuration with name 'testImplementation' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s

build.gradle

/* Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
*/

ext {
    apply from: 'cordova.gradle'
    cdvCompileSdkVersion = privateHelpers.getProjectTarget()
    cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        // The gradle plugin and the maven plugin have to be updated after each version of Android
        // studio comes out
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = 'org.apache.cordova'
version = '8.0.0'

android {
    compileSdkVersion cdvCompileSdkVersion
    buildToolsVersion cdvBuildToolsVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
    }
}

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                name 'Cordova'
                url 'https://cordova.apache.org'
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'stevengill'
                        name 'Steve Gill'
                    }
                }
                scm {
                    connection 'scm:git:https://github.com/apache/cordova-android.git'
                    developerConnection 'scm:git:git@github.com:apache/cordova-android.git'
                    url 'https://github.com/apache/cordova-android'

                }
            }
        }
    }
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

artifacts {
    archives sourcesJar
}

bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    configurations = ['archives']
    pkg {
        repo = 'maven'
        name = 'cordova-android'
        userOrg = 'cordova'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://github.com/apache/cordova-android'
        websiteUrl = 'https://cordova.apache.org'
        issueTrackerUrl = 'https://github.com/apache/cordova-android/issues'
        publicDownloadNumbers = true
        licenses = ['Apache-2.0']
        labels = ['android', 'cordova', 'phonegap']
        version {
            name = '8.0.0'
            released  = new Date()
            vcsTag = '8.0.0'
        }
    }
}

ionic info

Ionic:

   Ionic CLI          : 5.2.1 (C:\Users\Meftun\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.5
   @ionic/app-scripts : 3.2.2

Cordova:

   Cordova CLI       : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 5 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.7

System:

   Android SDK Tools : 26.1.1 (C:\Users\Meftun\AppData\Local\Android\sdk)
   NodeJS            : v10.16.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.10.0
   OS                : Windows 10

cordova plugin list

cordova-android-play-services-gradle-release 4.0.0 "cordova-android-play-services-gradle-release"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

As a result of my long research, I found the solution.

cordova platform rm android
cordova plugin rm cordova-plugin-firebase
cordova plugin add cordova-plugin-firebasex
cordova platform add android@latest

then

Change your all build.gradle file
Gradle Plugin as 3.0.0
Gradle Wrapper as 4.1

Replace the distributionUrl in android/cordova/lib/builder/ProjectsBuilder.js with 4.1

Good luck!

1 Like

selam dostum aynı hatayı bende alıyorum yardım etme şansın var mı

This could happen because you need to force upgrade gradle plugin.

you can force update the affected distributionURL file in platforms/android/cordova/lib/builders/ProjectBuilder.js

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-6.1.1-all.zip';