Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: com/android/build/api/dsl/CommonExtension #608

Open
Jadyli opened this issue Sep 15, 2022 · 4 comments
Open

Comments

@Jadyli
Copy link

Jadyli commented Sep 15, 2022

ktlint gradle version: 11.0.0
agp version: 7.2.2
gradle version: gradle-7.5.1-bin

After removing ktlint, the project can run sync and build normally.

java.lang.NoClassDefFoundError: com/android/build/api/dsl/CommonExtension
	at org.jlleitschuh.gradle.ktlint.android.AndroidPluginsApplierKt$androidPluginConfigureAction$1.invoke(AndroidPluginsApplier.kt:67)
	at org.jlleitschuh.gradle.ktlint.android.AndroidPluginsApplierKt$androidPluginConfigureAction$1.invoke(AndroidPluginsApplier.kt:66)
	at org.jlleitschuh.gradle.ktlint.android.AndroidPluginsApplierKt$applyKtLintToAndroid$1.invoke$lambda-0(AndroidPluginsApplier.kt:29)
	at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:123)
@dfavaro
Copy link

dfavaro commented Jan 12, 2023

Same here. Trying to integrate ktlint gradle in this template (multi-module branch) following the doc, into the root build.gradle. Getting the same error. Would appreciate some help.

@choongyouqi
Copy link

you will need com.android.application in your project gradle.

plugins {
    id("com.android.application") version "7.4.1" apply false
    id("org.jlleitschuh.gradle.ktlint") version "9.4.1" apply false
}

@wakingrufus
Copy link
Collaborator

version 12.1.0 of ktlint gradle came with fixes around AGP >= 7.0. Can you please retry with this version and report if it resolves your issue?
Thanks

@Sevastyan
Copy link

Having the same issue with version 12.1.1 even.

buildSrc/settings.gradle.kts:

dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {
            from(files("../gradle/libs.versions.toml"))
        }
    }
}

buildSrc/build.gradle.kts:

plugins {
    `kotlin-dsl`
}

repositories {
    gradlePluginPortal()
    google()
    mavenCentral()
}


dependencies {
    implementation(libs.gradlePlugin.ktlint)
}

buildSrc/src/main/kotlin/...gradle.kts:

plugins {
    id("org.jlleitschuh.gradle.ktlint")
}

libs.versions.toml:

...
[libraries]
gradlePlugin-ktlint = "org.jlleitschuh.gradle:ktlint-gradle:12.1.1"
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants