Gradle does not show any console output - linux

I try to run gradle on my CentOS machine but it does not print any output. Only stuff like gradle -v or gradle -q tasks brings some very basic information. The main problem is, that I get an compile error but it doesn't show me where it is.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
Cause: Compile failed; see the compiler error output for details.
JAVA_HOME and GRADLE_HOME are set. Classpath is empty. Any ideas?
gradle -v
Gradle 1.0-milestone-7
Gradle build time: Thursday, January 5, 2012 10:24:43 AM UTC
Groovy: 1.8.4
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_24 (Sun Microsystems Inc. 19.1-b02)
OS: Linux 2.6.18-274.17.1.el5 amd64

The compiler error output should show up above the FAILURE: Build failed with an exception message. -q provides less output than normal, but you can try -i. You can also have a look at the stack trace with -S. Last but not least I recommend to try a newer Gradle version (e.g. 1.0-rc-3).

I had the same issue and realised I was following tutorials that were using a lower version of gradlew than my gradle. So for example instead of:
gradle wrapper --gradle-version 2.13
Just use your gradle version or simply:
gradle wrapper
which will do so automatically.

I found this question while Googling because I was using Gradle but my own code's console output wasn't being logged to the command line during a test. Rather than my logged output from my own debugging statements, I was only getting extremely limited output like the following:
$ ./gradlew clean build
> Task :integrationTest
SystemTest > MyApp system test FAILED
org.opentest4j.AssertionFailedError at SystemTest.java:40
1 test completed, 1 failed
> Task :integrationTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':integrationTest'.
> There were failing tests. See the report at: file:///Users/me/repos/myFolder/my-app/build/reports/tests/integrationTest/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1/userguide/command_line_interface.html#sec:command_line_warnings
What I found was that the debug statements were actually being logged correctly. I just needed to go to the referenced test output HTML file and click on the "Standard Output" button. Once there, all of my logged debugging statements were present.

If the CLASSPATH is the issue, set it before you run your command; or better yet, set it in your .bashrc (or whatever your shell of choice is).
export $CLASSPATH=/path/to/java/

Related

How to fix failing the sync project with Gradle files?

`FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
Invalid revision: 3.22.1-g37088a8-dirty
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
CONFIGURE FAILED in 54s
Invalid revision: 3.22.1-g37088a8-dirty
`
I am using 3.1.2 version of android studio software. gradle version is 4.6. I am getting above error when I going to build the project. I tried change the gradle version to 4.4 too in gradle-wrapper.properties file. But anything didn't work. Can anyone have any solution as well as a reason why this happen?
As well as i have not set gradle in environment >> system variable. Because I thougtht It is installing to project from android studio. (Please tell something if there any wrong)

Sync ends with BUILD SUCCESSFUL but Make Project FAILS

All SO post on this subject (except for an unanswered one) describe the exact opposite situation: Build successful but Sync fails.
My situation is that I installed Android Studio for the first time (2021.3.1.17) and successfully imported an old (but working) Eclipse/ADT project of mine: Sync completes successfully, albeit with several warnings:
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1s
It also warns about the Java version:
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in C:\Program Files\Java\jdk1.8.0_341\jre
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
Gradle settings
But when I try to Build > Make Project, it surprisingly ends with an ERROR:
Build file 'C:\Users\WebViewer\StudioProjects\MyApp\billing\build.gradle' line: 1
A problem occurred evaluating project ':billing'.
> Failed to apply plugin 'com.android.internal.library'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in C:\Program Files\Java\jdk1.8.0_341\jre
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
I understand the warnings (definitely good ones, prompting to update to current versions, and I eliminated the Java version one via File > Settings > Build Tools > Gradle) but... if Sync ends successfully, why would Make Project fail completely?
As a newcomer to Android Studio (IntelliJ + Gradle), I am confused by this discrepancy. Could someone please shed light on the essential difference between Sync, Make Project and Rebuild Project?

FAILURE: Build failed with an exception. creating node js apps

I'm using cordova to create apps and when I used the command
cordova build android I got this error through the CLI:
c:\Apps\projeto_1>cordova build android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\Max\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Program Files (x86)\Android\android-sdk
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Starting Daemon
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 7s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
Where:
Script 'C:\Apps\projeto_1\platforms\android\CordovaLib\cordova.gradle' line: 75
What went wrong:
A problem occurred evaluating script.
No usable Android build tools found. Highest 30.x installed version is 29.0.3; minimum version required is 30.0.3.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
Command failed with exit code 1: c:\Apps\projeto_1\platforms\android\gradlew cdvBuildDebug -b c:\Apps\projeto_1\platforms\android\build.gradle
Example of build failure: Build failed with an exception.
Where:
Script 'C:\Apps\projeto_1\platforms\android\CordovaLib\cordova.gradle' line: 75
What went wrong:
A problem occurred evaluating script.
No usable Android build tools found. Highest 30.x installed version is 29.0.3; minimum version required is 30.0.3.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
Command failed with exit code 1: c:\Apps\projeto_1\platforms\android\gradlew cdvBuildDebug -b c:\Apps\projeto_1\platforms\android\build.gradle

Gradle: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

I saw this gradle error: "Could not initialize class org.codehaus.groovy.runtime.InvokerHelper". I have tried multiple ways listed online to fix the issue but no luck.
During the debugging, I found weird JVM version.
Installed Java 14 and I have set the path in JAVA_HOME in bash_profile. However, gradle shows JVM 13 version. I am not sure if this cause the error: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
My java version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
Gradle version, but not sure why JVM shows 13
Gradle 6.5
------------------------------------------------------------
Build time: 2020-06-02 20:46:21 UTC
Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: **13.0.2 (Oracle Corporation 13.0.2+8)**
OS: Mac OS X 10.14.6 x86_64
Gradle error
npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
change the version of the gradle
edit the file in YOUR_PROJECT/android/gradle/wrapper/gradle-wrapper.properties and change the version
FROM:
distributionUrl=https://services.gradle.org/distributions/gradle-6.0.1-all.zip
TO:
distributionUrl=https://services.gradle.org/distributions/gradle-6.4.1-all.zip
source: https://github.com/gradle/gradle/issues/10248#issuecomment-633656326
Gradle is very specific about the Java Version. We need to check the compatibility matrix and set the java version to be needed by the gradle version.
https://docs.gradle.org/current/userguide/compatibility.html
The issues related to starting a gradle daemon are mostly because of JAVA. We don't need to upgrade or downgrade gradle version. No change in settings file needed.
You need to change the Gradle version of your project.
It's mentioned in the official docs: https://reactnative.dev/docs/environment-setup
"If you're using the latest version of Java Development Kit, you'll need to change the Gradle version of your project so it can recognize the JDK. You can do that by going to {project root folder}\android\gradle\wrapper\gradle-wrapper.properties and changing the distributionUrl value to upgrade the Gradle version. You can check out here the lastest releases of Gradle."
or see this image
The above mentioned error is very similar to what I faced when starting off with react-native development. This error is caused due to incompatible JAVA JDK and Gradle version in the project. Head to ./android/gradle/wrapper/gradle-properties ..... and change the
required gradle version.

java.security.NoSuchAlgorithmException while building a simple android app using Android Studio

I downloaded the Android Studio and trying to build a simple Login Activity. But the Make Project fails with this error.
Environment: Windows 7 64 bit
Gradle:
trouble writing output: java.security.NoSuchAlgorithmException: SHA-1 MessageDigest not available
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':MyApp:dexDebug'.
Running C:\Program Files (x86)\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat failed. See output
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I have made sure the Gradle zip was downloaded and installed properly
Any hints what else should I check for?
I was using IBM JDK. Switching to Sun/Oracle JDK fixed the problem.

Resources