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

Update to Gradle 8.0 and Java 17 #668

Open
andrea157 opened this issue Apr 28, 2023 · 5 comments
Open

Update to Gradle 8.0 and Java 17 #668

andrea157 opened this issue Apr 28, 2023 · 5 comments
Assignees

Comments

@andrea157
Copy link

After updating Android Studio to Flamingo | 2022.2.1, upgrading AGP to 8.0 and moving from Java 11 to Java 17 I started having problems;
I have errors about the dependency of task addKtlintCheckGitPreCommitHook to other tasks.

Adding tasks.getByName("addKtlintCheckGitPreCommitHook") dependsOn(":app:createDebugVariantModel") the build now works but the tests keep failing; every run reports dependencies to tasks of other modules and even if I add them as dependencies every run there is always another task that gives errors like this

Some problems were found with the configuration of task ':addKtlintCheckGitPreCommitHook' (type 'KtlintInstallGitHookTask').
  - Gradle detected a problem with the following location: '.../AndroidStudioProjects/App/app'.
    
    Reason: Task ':addKtlintCheckGitPreCommitHook' uses this output of task ':module-name:...' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':module-name:...' as an input of ':addKtlintCheckGitPreCommitHook'.
      2. Declare an explicit dependency on ':module-name:...' from ':addKtlintCheckGitPreCommitHook' using Task#dependsOn.
      3. Declare an explicit dependency on ':module-name:...' from ':addKtlintCheckGitPreCommitHook' using Task#mustRunAfter.

Any suggestions? Thanks

@HylkeB
Copy link

HylkeB commented May 11, 2023

I have the same issue, not on the PreCommitHook but on the test sourcesets, also since updating to gradle 8.0, java 17 and kotlin 1.8.20 (not sure which caused the issues)

The errors I get are both on ktlintCheck and ktlintFormat:

  - Gradle detected a problem with the following location: '<projectdir>/build/generated/ksp/android/androidUnitTestDebug/kotlin'.
    
    Reason: Task ':<module>:runKtlintCheckOverCommonTestSourceSet' uses this output of task ':<module>:kspDebugUnitTestKotlinAndroid' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':<module>:kspDebugUnitTestKotlinAndroid' as an input of ':<module>:runKtlintCheckOverCommonTestSourceSet'.
      2. Declare an explicit dependency on ':<module>:kspDebugUnitTestKotlinAndroid' from ':<module>:runKtlintCheckOverCommonTestSourceSet' using Task#dependsOn.
      3. Declare an explicit dependency on ':<module>:kspDebugUnitTestKotlinAndroid' from ':<module>:runKtlintCheckOverCommonTestSourceSet' using Task#mustRunAfter.
    
    Please refer to https://docs.gradle.org/8.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '<projectdir>/build/generated/ksp/android/androidUnitTestDebug/kotlin'.
    
    Reason: Task ':<module>:runKtlintFormatOverCommonTestSourceSet' uses this output of task ':<module>:kspDebugUnitTestKotlinAndroid' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':common:mag-core:kspDebugUnitTestKotlinAndroid' as an input of ':<module>:runKtlintFormatOverCommonTestSourceSet'.
      2. Declare an explicit dependency on ':<module>:kspDebugUnitTestKotlinAndroid' from ':<module>:runKtlintFormatOverCommonTestSourceSet' using Task#dependsOn.
      3. Declare an explicit dependency on ':<module>:kspDebugUnitTestKotlinAndroid' from ':<module>:runKtlintFormatOverCommonTestSourceSet' using Task#mustRunAfter.
    
    Please refer to https://docs.gradle.org/8.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

Same workaround works for me as well:

tasks.getByName("runKtlintCheckOverCommonTestSourceSet").dependsOn("kspDebugUnitTestKotlinAndroid")
tasks.getByName("runKtlintFormatOverCommonTestSourceSet").dependsOn("kspDebugUnitTestKotlinAndroid")

@andrea157
Copy link
Author

Yes I tried to add the dependency like you but every time it reports a dependency to another task, I've added up to 20 dependencies, but still each build requires another new task 🥲

@Tgo1014
Copy link

Tgo1014 commented Aug 23, 2023

Also suffering from this issue. The app has 30 modules and every time I add one dependency it asks for more and more, would take hours to add everything as dependency. Any workaround for this one?

@wakingrufus wakingrufus self-assigned this Aug 23, 2023
@kartikprakash1
Copy link

Any updates on this issue or workarounds?

@JLLeitschuh
Copy link
Owner

Not at this time. Happy to accept a pull request that addresses these problems as long as an associated unit test is included 🙂

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

6 participants