6

Unable to load class 'org.gradle.api.publication.maven.internal.MavenPomMetaInfoProvider'.

apply plugin: 'com.github.dcendents.android-maven'

The following were changes done in app after gradle update in gradle/wrapper/gradle-wrapper.properties

-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

and under build.gradle

-        classpath 'com.android.tools.build:gradle:4.2.2'
+        classpath 'com.android.tools.build:gradle:7.0.0'

-        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
+        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'

Adding app level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        kotlin_version = '1.5.10'
    }
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Denny Mathew
  • 842
  • 3
  • 13
  • 31
  • look at this https://stackoverflow.com/questions/37086806/android-studio-failed-to-apply-plugin-id-com-android-application – A Farmanbar Aug 02 '21 at 13:09
  • looks there is a incompatibility versions – A Farmanbar Aug 02 '21 at 13:10
  • The plugin android-maven-gradle-plugin seems to be deprecated since the android-gradle-plugin now supports publishing to maven. See if this article helps? https://developer.android.com/studio/build/maven-publish-plugin I don't think I will be able to help further unless you can share some more details on gradle config code, or how your maven publishing is configured, or a reproducible build. – Kenny John Jacob Aug 04 '21 at 13:30
  • I had similar build issue while working in the arctic fox. I am not sure but this might help you - https://stackoverflow.com/a/68664590/6390459 – Shunan Aug 06 '21 at 04:03
  • what version of java you are using – Milan Tejani Aug 06 '21 at 14:49
  • compileOptions { targetCompatibility = "8" sourceCompatibility = "8" } – Denny Mathew Aug 06 '21 at 15:10
  • Can I see both module and app build.gradle because the error might be in one of those. – avs Aug 06 '21 at 19:31
  • What is your purpose of using com.github.dcendents.android-maven? This is a deprecated library. – Arda Kazancı Aug 09 '21 at 09:52
  • it was there by default, I am not sure how it got added in the first place. but it became an issue after I got the upgrade to arctic fox gradle 7.0.0 – Denny Mathew Aug 09 '21 at 12:06
  • https://developer.android.com/jetpack/compose/interop/adding?authuser=1#setup – Denny Mathew Aug 25 '21 at 02:30

3 Answers3

2

After I made the upgrade to Artic Fox, I had to set the proper SDK for gradle in settings for things to work. By default after the update, it was still using Java 1.8, although JAVA_HOME was set properly and I had issues when applying com.android.application plugin.

Also, I removed all the JVM target params from gradle files

Gradle Settings

Cristian Holdunu
  • 1,880
  • 1
  • 18
  • 43
2

Can you switch your,

classpath 'com.android.tools.build:gradle:7.0.0'

to,

classpath 'com.android.tools.build:gradle:4.2.0' // or 4.2.2

According to Gradle Plugin Release Notes I cannot see 7.0.0 listed there.

Alish Giri
  • 1,855
  • 18
  • 21
  • yes, as per the question. reverting it back always works. it is an attempt to upgrade to gradle 7.0.0, which is not working. – Denny Mathew Aug 08 '21 at 13:28
1

The maven plugin hase been removed from Gradle 7 . Check the documentation . Now you should use maven-publish plugin , to activate it add

plugins {
    id 'maven-publish'
}

or

apply plugin: 'maven-publish'

in your build script, instead using apply plugin: 'com.github.dcendents.android-maven'

Otherwise you have to roll back to older Gradle version.

Zahid Islam
  • 740
  • 1
  • 5
  • 11