google errorprone java.lang.NoSuchMethodError - gradle

We are facing a strange problem. We are using net.ltgt.errorprone, version (0.0.8), along with guava(version 21) and gradle(version 3.1). Everything was working fine till today's morning. But suddenly all developers started getting this error
[system.err] An exception has occurred in the compiler (1.8.0_162). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NoSuchMethodError: com.google.common.base.Verify.verify(ZLjava/lang/String;Ljava/lang/Object;)V
at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:132)
We searched through internet, most of the solutions are related to guava, but there was no change in guava version or
errorprone or gradle since a long time. We tried running old code also, getting the same error. We are unable to understand root cause of the problem. Did anyone face the same problem?

com.google.collections:google-collections was renamed to com.google.guava:guava which is really annoying and can often lead to two versions of the library on the classpath.
Here's how I'd diagnose the problem
Run gradle dependencies in the "broken" build
Go back in history in source control (git?) until you have a working version
Run gradle dependencies in the "working" build
Look for differences in versions of com.google.collections:google-collections
Look for differences in versions of com.google.guava:guava
See here in the Gradle docs where guava rename is discussed
You might need to add this to build.gradle
dependencies {
modules {
module("com.google.collections:google-collections") {
replacedBy("com.google.guava:guava", "google-collections is now part of Guava")
}
}
}

A new version(2.3.0) of errorprone was released, this broke our build.
We find out the dependency using this command
./gradlew -q dependencyInsight --configuration errorprone --dependency error_prone_core
This clearly showed that latest version is being used. We fixed it by using a last workable version forcefully. Following lines were added to build.gradle file
configurations.all {
resolutionStrategy {
force 'com.google.errorprone:error_prone_core:2.2.0'
}
}

Related

How to View Gradle module dependencies?

The following error occurs when gradle builds
Duplicate class androidx.lifecycle.ViewModelLazy found in modules lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1) and lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1)
Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1) and lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1)
Go to the documentation to learn how to Fix dependency resolution errors.
So I found the following documentation:
link
But I can't find AppName > Tasks > android. I noticed the following tip:
So I opened the settings and unchecked the Do not build Gradle task list during Gradle sync
but this still doesn't work.
I already know the answer to this question, when you run the gradle command once, the interface will appear.
gradle app:dependencies

Android build failed: Could not resolve all files for configuration ':debugCompileClasspath'

I'm new to Android development and keep running into this specific error when I try building my test app via the Windows command: python setup.py android -s:
Could not resolve all files for configuration ':debugCompileClasspath'
Could not find com.android.support:appcompat-v7:25.1.1.
So how do I resolve all files for configuration?
After several hours of troubleshooting, related answers to this question have not worked for me. For instance, I have tried manipulating my build.gradle file in the following manner:
Modified maven() to maven {url "https://maven.google.com" }
Modified jcenter() to jcenter { url "http://jcenter.bintray.com/" }
Moved jcenter... to be the last item in the list under repositories { .... (there is no allprojects { ... category)
Added buildToolsVersion "27.0.3" under android { ....
Modified the classpath version to the latest gradle version 3.1.0 like so classpath 'com.android.tools.build:gradle:3.1.0' (it was initially using an out of date version)
Updated Android Studio IDE
Uninstalled and reinstalled all SDK-tools under the SDK Manager
(Full build.gradle here, on pastebin)
The only remaining helpful hint I have here is the information provided by the log.
It tells me that it can't find files in directories on my hard drive. All other related outputs I've seen from others is the location specifiying actual websites related to google or gradle.
Could not resolve all files for configuration ':debugCompileClasspath'.
> Could not find com.android.support:appcompat-v7:25.1.1.
Searched in the following locations:
file:/C:/Users/USERNAME/AppData/Local/Android/sdk/extras/m2repository/com/android/support/appcompat-v7/25.1.1/appcompat-v7-25.1.1.pom
file:/C:/Users/USERNAME/AppData/Local/Android/sdk/extras/m2repository/com/android/support/appcompat-v7/25.1.1/appcompat-v7-25.1.1.jar
file:/C:/Users/USERNAME/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/25.1.1/appcompat-v7-25.1.1.pom
file:/C:/Users/USERNAME/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/25.1.1/appcompat-v7-25.1.1.jar
file:/C:/Users/USERNAME/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/25.1.1/appcompat-v7-25.1.1.pom
file:/C:/Users/USERNAME/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/25.1.1/appcompat-v7-25.1.1.jar
I also have this error, which may or may not contribute to the files not being in the specified directory:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.7/userguide/command_line_interface.html#sec:command_line_warnings
Can anyone help me troubleshoot this issue and essentially resolve all files for configuration so that I can run my test app? Any help is greatly appreciated. Feel free to let me know if there's any additional I can provide.

Eclipse JDT LS & Gradle - Resource Exception "Invalid project description"

Summary
I've been trying to get Eclipse's JDT LS (JLS) working with vim-lsp (in Neovim), but have been unsuccessful in synchronising the JLS with a Gradle project. I am, unfortunately, constrained to Windows.
The Problem
Using this configuration (commit #d1c7a25 at the time of posting), I cannot synchronise the JLS with a Gradle project "due to an error configuring Eclipse" because of an "invalid project description" (see log).
Trawling through Google and the GitHub issues of both the JLS and vim-lsp plugin has gotten me nowhere.
Remarks
I feel like it's most likely an issue with my configuration. If anyone has got this working with other LSP plugins aside from YouCompleteMe (such as CoC or LanguageClient) those setups are also welcome, but vim-lsp is preferred.
To reiterate, and just in case:
Windows 10 Pro (v1803 build 17134.407)
Neovim (v0.3.1) with plugin vim-lsp
Gradle wrapper (v4.10.2)
Eclipse JDT LS (v0.28.0 build 201811140630) [.tar.gz]
using this configuration (originally #d1c7a25)
Thanks!
Figured it out.
The workspace directory for the JLS (specified by the command line argument -data) can't be nested under the project's own directory.
*bashes head on desk*

Project won't compile in IntelliJ IDEA after adding Maven support because of complaints about the JDK version

I'm using IntellJ 14.1.4 Community Edition
My project compiled fine before (I have it set up to use the Eclipse compiler)
But I tried to Mavenize it...
I added Maven via the Add Framework | Maven command
Now my problem is (still using the Eclipse Compiler)...
It gives me error messages like:
Error:(21, 78) java: '<>' operator is not allowed for source level below 1.7
Which leads me to suspect that it is not compiling to 1.8
However, I didn't change anything other than Mavenizing it
The Project SDK in IDEA is set to use 1.8
I did notice some setting about bytecode being 1.5.. but i tried to change that to 1.8 but still get this error message.
Anyone have any clue what's going on?
this was essentially the correct advice of course - in the comments, however I had been trying to do it for a long time both via maven-compiler-plugin and properties... to no success, even though I was refreshing Maven after making changes to pom.xml. Finally, I restarted the IDE .. and .. it works! I can compile..

findbugsMain task in gradle fails

I'm trying to run the findbugsMain task in Gradle 1.10 (or more specific "gradlew check") but the only thing I get is an error like
building findbugsMain 33% > ...
:findbugsMain FAILED
It seems to download the required jars though:
...
Download http://repo1.maven.org/maven2/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar
Download http://repo1.maven.org/maven2/asm/asm/3.3/asm-3.3.jar
Download http://repo1.maven.org/maven2/asm/asm-tree/3.3/asm-tree-3.3.jar
Download http://repo1.maven.org/maven2/asm/asm-commons/3.3/asm-commons-3.3.jar
Download http://repo1.maven.org/maven2/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
Download http://repo1.maven.org/maven2/jdom/jdom/1.0/jdom-1.0.jar
Download http://repo1.maven.org/maven2/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar
Download http://repo1.maven.org/maven2/xom/xom/1.0/xom-1.0.jar
Download http://repo1.maven.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar
Download http://repo1.maven.org/maven2/xalan/xalan/2.6.0/xalan-2.6.0.jar
Download http://repo1.maven.org/maven2/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar
:findbugsMain FAILED
I ran the task using --stacktravce again and this is what I got:
Pastebin link
My build.gradle is also on Pastebin
I'm relatively new to build management tools in general and gradle in particular, so it might be my fault (e.g. buildscript has an error).
Judging from the stack trace, some internal error occurs. This could be due to an incompatibility between the version of the ASM library used by Gradle, and the version expected by FindBugs. Would you mind to file an issue over at http://forums.gradle.org, ideally including a minimal reproducible example?
As it seems FindBugs up to version 2.0.3 has problems with some Java 8 classfiles. These
problems will be addressed in the next major version of FindBugs. Until then you have to use Java 7.
So, the short version is, that I changed the language level to 1.7 and everything runs just fine now.
Thanks #peter for the help.

Resources