gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
91 stars 8 forks source link

After some update last week I could not build even the clean new project #1101

Open Gelassen opened 1 year ago

Gelassen commented 1 year ago

Description

I have been working on android project over Android Studio last week. After some update, I don't remember which one, I start having issues with build&run projects and tests. Build error point out on issue with gradle, but quick internet search shows it might be just a consequence of some others issue, e.g. plugin versions mismatch. I had to isolate the issue to find out which part fails and I ended up likely it is gradle.

What was done:

  1. Downloaded the latest android studio release (it is supplied with own JDK, therefore JDK as a possible root cause is excluded)
  2. Open and build some of my previous projects (exclude any change in build.gradle or *.properties files as a possible root cause)
  3. Start a new fresh project and build it (exclude the most of project dependencies to avoid dependencies versions mismatch as a possible root cause).

In all three cases I receives the same issue:


* Where:
Script '/home/gelassen/.gradle/init.d/build-result-capture-service.plugin.groovy' line: 48

* What went wrong:
Failed to stop service 'gradle-build-action-buildResultsRecorder'.
> Ambiguous method overloading for method java.io.File#<init>.
  Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between:
        [class java.io.File, class java.lang.String]
        [class java.lang.String, class java.lang.String]

This file by itself:

`~/.gradle/init.d$ cat build-result-capture-service.plugin.groovy import org.gradle.tooling.events. import org.gradle.tooling.events.task. import org.gradle.util.GradleVersion

// Can't use settingsEvaluated since this script is applied inside a settingsEvaluated handler // But projectsEvaluated is good enough, since the build service won't catch configuration failures anyway projectsEvaluated { def projectTracker = gradle.sharedServices.registerIfAbsent("gradle-build-action-buildResultsRecorder", BuildResultsRecorder, { spec -> spec.getParameters().getRootProjectName().set(gradle.rootProject.name) spec.getParameters().getRootProjectDir().set(gradle.rootProject.rootDir.absolutePath) spec.getParameters().getRequestedTasks().set(gradle.startParameter.taskNames.join(" ")) spec.getParameters().getGradleHomeDir().set(gradle.gradleHomeDir.absolutePath) spec.getParameters().getInvocationId().set(gradle.ext.invocationId) })

gradle.services.get(BuildEventsListenerRegistry).onTaskCompletion(projectTracker)

}

abstract class BuildResultsRecorder implements BuildService, OperationCompletionListener, AutoCloseable { private boolean buildFailed = false interface Params extends BuildServiceParameters { Property getRootProjectName() Property getRootProjectDir() Property getRequestedTasks() Property getGradleHomeDir() Property getInvocationId() }

public void onFinish(FinishEvent finishEvent) {
    if (finishEvent instanceof TaskFinishEvent && finishEvent.result instanceof TaskFailureResult) {
        buildFailed = true
    }
}

@Override
public void close() {
    def buildResults = [
        rootProjectName: getParameters().getRootProjectName().get(),
        rootProjectDir: getParameters().getRootProjectDir().get(),
        requestedTasks: getParameters().getRequestedTasks().get(),
        gradleVersion: GradleVersion.current().version,
        gradleHomeDir: getParameters().getGradleHomeDir().get(),
        buildFailed: buildFailed,
        buildScanUri: null,
        buildScanFailed: false
    ]

    def buildResultsDir = new File(System.getenv("RUNNER_TEMP"), ".build-results")
    buildResultsDir.mkdirs()
    def buildResultsFile = new File(buildResultsDir, System.getenv("GITHUB_ACTION") + getParameters().getInvocationId().get() + ".json")
    buildResultsFile << groovy.json.JsonOutput.toJson(buildResults)
}

} `

Expected Behavior

I create new project over the latest officially released Android Studio, build it - it successfully compiles and runs on emulator.

Current Behavior

Neither my current project in work or just newly created project on build&run failed with exception above.

Context

I can not continue work on app without solving or finding a hack for this issue

Steps to Reproduce (for bugs)

  1. Download the latest officially released Android Studio
  2. Install it
  3. Create a new project (I created a new project with empty activity)
  4. Click build&run button over IDE to build project and run on emulator (I used Nexus 5 API 30)

Your Environment

Android Studio

Android Studio Chipmunk | 2021.2.1 Patch 1
Build #AI-212.5712.43.2112.8609683, built on May 18, 2022
Runtime version: 11.0.12+0-b1504.28-7817840 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-121-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: idea.plugin.protoeditor (212.5080.8), org.jetbrains.kotlin (212-1.7.10-release-333-AS5457.46)
Current Desktop: ubuntu:GNOME

Gradle Properties

#Mon Jul 11 06:34:38 MSK 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME