-
-
Notifications
You must be signed in to change notification settings - Fork 758
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
Applying Detekt from external Gradle file fails with: Unable to load class 'com.android.build.gradle.BaseExtension' #3490
Comments
In your root project, did you apply both detekt plugin and |
Which version of AGP are you on? |
@chao2zhang actually i didn't applied it inside root project gradle. The |
Does your feature module apply |
@chao2zhang actually they are not android feature modules, they are basically gradle library modules which i develop features inside them. Because of this, the module gradle file which i applied detekt script contains
However when i add detekt dependency also to the app gradle, which contains
The problem is still valid. |
This looks weird. Detekt has gradle testkit integration tests for both I can try to reproduce this, but as far as I know my project is also on AGP 4.1.2 and has no problem running detekt. |
I forgot to mention but https://github.com/cortinico/kotlin-android-template also works with detekt. It has both library and app modules. |
Actually problem is not detekt but how i applied it. If i choose a standard way to implement, there are no problems.
But if i choose the implementation that i mentioned in issue desc
Then the problem raises. It isn't very hard to convert this into working one. But i wonder why this approach fails. This line may be the problematic one |
I can back this up. We use the same initialization in a secondary gradle file and tried to update from 1.1.0 to 1.16.0 (I know this is a huge jump). But we used this approach because in our company we have many projects and we need to have the same detekt setup in all projects so copy-pasting files are faster and way more convenient for new project setup. |
@volsahin Could you elaborate why we need @sigis151 @volsahin I am also trying to find problematic commits between 1.11.1 and 1.12.0 - There are also 1.11.2 and 1.12.0-RC1, would you mind checking if those versions work or not? |
My suspicion is that we introduced android plugin configuration in 1.12.0 - #2787, which may conflict with the existing android projects setup. |
|
I guess we have verified that it is extremely likely to be broken with #2787. Would you mind sharing a sample project? I have tried to use Meanwhile, I can open a new PR to allow folks to opt-out DetektAndroid setup. |
fos sample I have quality.gradle
And in main
|
@chao2zhang is this issue fixed with PR #3511? Is there anything else left to do in order to close this issue? |
Nope is still not solved. The root cause is applying detekt from an external build file (say |
Heyo 👋 I got some time to look into this. The reason why you're experiencing a The reason is that Detekt added support for Android & Multiplatform targets in recent versions. Since we don't want to impose a transitive dependency on AGP, we declared it as a As a side note, I would like to discourage usage of external build files, for a variety of reasons:
Instead please consider using precompiled script plugins. See https://docs.gradle.org/current/userguide/custom_plugins.html#sec:precompiled_plugins If you don't need the Detekt Android support, you can disable it entirely using the capability offered in #3511 Below you can find the updated the snippet you provided @sigis151. They work correctly for me locally: top level build.gradle
app build.gradle
quality.gradle
|
Steps to Reproduce
I intended to upgrade detekt version from 1.9.1 to latest 1.16.0-RC1 in android project and build failed.
The project uses classic groovy gradle files. It is nice to mention that i apply detekt as a seperate gradle script.
Here is the current detekt.gradle script
And that is how it's applied into app
apply from: '../scripts/detekt.gradle'
As i see 1.11.1 is the latest version which can be built without a problem. Starting 12.0.0 to the latest version, build fails.
Gradle plugin versions are the latest one.
Stacktrace
Also #3476 #3260 these issues experienced similar exceptions as far as i can see.
Environment
The text was updated successfully, but these errors were encountered: