Skip to content

NoSuchMethodError: 'org.gradle.api.provider.Property org.gradle.api.reporting.ConfigurableReport.getOutputLocation()' on Gradle 7.5.1 #302

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

Closed
rmarma opened this issue Aug 16, 2023 · 3 comments · Fixed by #304
Assignees
Labels

Comments

@rmarma
Copy link

rmarma commented Aug 16, 2023

On Gradle 7.5.1 when I try to get a jacoco report, or a list of tasks, I get this error:

What went wrong
Execution failed for task ':app:tasks'.
> Could not create task ':app:jacocoTestReportDebug'.
   > 'org.gradle.api.provider.Property org.gradle.api.reporting.ConfigurableReport.getOutputLocation()'

Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:tasks'
...
Caused by: java.lang.NoSuchMethodError: 'org.gradle.api.provider.Property org.gradle.api.reporting.ConfigurableReport.getOutputLocation()'
        at de.mannodermaus.gradle.plugins.junit5.internal.extensions.ConfigurableReportExtKt.getOutputLocationFile(ConfigurableReportExt.kt:7)
        at de.mannodermaus.gradle.plugins.junit5.tasks.AndroidJUnit5JacocoReport$ConfigAction.execute(AndroidJUnit5JacocoReport.kt:101)

It works fine on Gradle 8.2.1.

Steps to Reproduce

Create an empty project on Gradle 7.5.1:
root build.gradle.kts:

plugins {
    id("com.android.application") version "7.4.2" apply false
    id("org.jetbrains.kotlin.android") version "1.8.22" apply false
    id("de.mannodermaus.android-junit5") version "1.9.3.0" apply false
}

app build.gradle.kts:

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    jacoco
    id("de.mannodermaus.android-junit5")
}
configure<AndroidJUnitPlatformExtension> {
    jacocoOptions {
        html {
            enabled = true
            destination = layout.buildDirectory.file("reports/jacoco/${name}.html").get().asFile
        }
    }
}

Run

./gradlew :app:tasks

Environment

  • macOS 13.5
  • JDK jbr-17.0.8
  • Android Studio Giraffe | 2022.3.1
  • Gradle 7.5.1
  • AGP 7.4.2
  • Kotlin 1.8.22
  • Android-junit5 1.9.3.0
@rmarma
Copy link
Author

rmarma commented Aug 17, 2023

I haven't figured out exactly what the cause of the problem is, but probably this quick fix should solve this issue.

@mannodermaus
Copy link
Owner

Hey, thanks for reporting. The Gradle folks changed the return type of Report.outputLocation in an unexpected manner between Gradle 7.5.1 and Gradle 8.x (link). It used to be a Provider<T> and now it's a Property<T>, which is what the codebase currently expects as well. It should be possible to resolve the hierarchy in a way that supports both the old and new type signature, but it's unfortunate that the current functional tests did not catch this. I'm going to surface the issue in tests first and then tackle this!

@mannodermaus mannodermaus self-assigned this Aug 18, 2023
mannodermaus added a commit that referenced this issue Aug 18, 2023
…e versions

There is a binary incompatibility between Gradle 7 and 8 that changed the return type
of `outputLocation`. Catch an error with the new method and fall back to a safe alternative
(see #302)
mannodermaus added a commit that referenced this issue Aug 18, 2023
…location of Jacoco reports (#304)

* Add test project to expose NoSuchMethodError with Jacoco on AGP 7.4 and Gradle 7.5

* Use fallback to access Jacoco report output location from older Gradle versions

There is a binary incompatibility between Gradle 7 and 8 that changed the return type
of `outputLocation`. Catch an error with the new method and fall back to a safe alternative
(see #302)
@mannodermaus
Copy link
Owner

This should be available in the latest 1.10.0.0-SNAPSHOT of the plugin and will be part of its full release in a little while. Thanks again!

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