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/gradle/AppPlugin #47

Closed
Egorand opened this issue Dec 24, 2017 · 7 comments
Closed

java.lang.NoClassDefFoundError: com/android/build/gradle/AppPlugin #47

Egorand opened this issue Dec 24, 2017 · 7 comments

Comments

@Egorand
Copy link

Egorand commented Dec 24, 2017

Gradle 4.4.1, Android Gradle Plugin 3.0.1

I'm trying to add the plugin to https://github.com/hzsweers/CatchUp via the plugins block in the top-level build.gradle file. The build fails with the following error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':app:kapt'.
      > A problem occurred configuring project ':bypass'.
         > Failed to notify project evaluation listener.
            > com/android/build/gradle/BaseExtension
   > com/android/build/gradle/BaseExtension

Here's a part of the stacktrace that looks relevant:

Caused by: java.lang.NoClassDefFoundError: com/android/build/gradle/BaseExtension
        at org.jlleitschuh.gradle.ktlint.KtlintPlugin$addKtLintTasksToAndroidKotlinPlugin$1$1.execute(KtlintPlugin.kt:72)
        at org.jlleitschuh.gradle.ktlint.KtlintPlugin$addKtLintTasksToAndroidKotlinPlugin$1$1.execute(KtlintPlugin.kt:26)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
        ... 153 more
Caused by: java.lang.ClassNotFoundException: com.android.build.gradle.BaseExtension
        ... 161 more

Any special considerations when running the plugin on Android?

@Tapchicoma
Copy link
Collaborator

Support for Android gradle 3.x plugin is already merged into master, but new plugin version hasn't been released.

@JLLeitschuh will do soon a new plugin release.

@Egorand
Copy link
Author

Egorand commented Dec 25, 2017

Great, thanks!

@Egorand Egorand closed this as completed Dec 25, 2017
@JLLeitschuh
Copy link
Owner

This has just been published as version 3.0.0

@Egorand
Copy link
Author

Egorand commented Dec 25, 2017

I tried it out and I seem to be getting a similar error:

Caused by: java.lang.NoClassDefFoundError: com/android/build/gradle/AppPlugin
        at org.jlleitschuh.gradle.ktlint.KtlintPlugin$addKtLintTasksToAndroidKotlinPlugin$1$1.execute(KtlintPlugin.kt:77)
        at org.jlleitschuh.gradle.ktlint.KtlintPlugin$addKtLintTasksToAndroidKotlinPlugin$1$1.execute(KtlintPlugin.kt:31)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
        ... 153 more

Is my understanding correct that I should just add id "org.jlleitschuh.gradle.ktlint" version "3.0.0" to the plugins block in the top-level build.gradle when setting up an Android project?

@Egorand Egorand reopened this Dec 25, 2017
@Egorand Egorand changed the title java.lang.ClassNotFoundException: com.android.build.gradle.BaseExtension java.lang.NoClassDefFoundError: com/android/build/gradle/AppPlugin Dec 25, 2017
@Tapchicoma
Copy link
Collaborator

Tapchicoma commented Dec 26, 2017

In your case you have applied ktlint plugin via plugins block, while project applies android gradle plugin using old-way via classpath. Such scenario seems not working as ktlint can't find expected classes from android plugin.

I've tried to apply ktlint via classpath to this project and it works.

@Egorand
Copy link
Author

Egorand commented Dec 26, 2017

Oh right, that makes sense. The old way seems to work, thanks for the help!

@Egorand Egorand closed this as completed Dec 26, 2017
@ganeshpadhayay
Copy link

If anyone is still facing this issue, then please check the compatibility of Gradle version used in the project and the version of Gradle plugin which studio is using

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

4 participants