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:
Downloaded the latest android studio release (it is supplied with own JDK, therefore JDK as a possible root cause is excluded)
Open and build some of my previous projects (exclude any change in build.gradle or *.properties files as a possible root cause)
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]
// 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)
})
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)
Download the latest officially released Android Studio
Install it
Create a new project (I created a new project with empty activity)
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
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:
In all three cases I receives the same issue:
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) })
}
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()
}
} `
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)
Your Environment
Android Studio
Gradle Properties