I've installed gradle on MAC using terminal.
brew install gradle
Gradle has been installed successfully.
gradle -v
------------------------------------------------------------
Gradle 3.3
------------------------------------------------------------
Build time: 2017-01-03 15:31:04 UTC
Revision: 075893a3d0798c0c1f322899b41ceca82e4e134b
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_112 (Oracle Corporation 25.112-b16)
OS: Mac OS X 10.12.3 x86_64
but I can not find gradle home.
echo $GRADLE_HOME
[empty result]
the first step to determine home directory is detect location of gradle instruction:
which gradle
/usr/local/bin/gradle
there is incomprehensible bash file.
Any ideas how to detect gradle home directory via terminal?
You can use command:
brew info gradle
As the result you will have something like this:
gradle: stable 4.0.1
Build system based on the Groovy language
https://www.gradle.org/
/usr/local/Cellar/gradle/3.4 (181 files, 74.5MB) *
Built from source on 2017-02-24 at 15:01:34
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gradle.rb
==> Requirements
Required: java >= 1.7 ✔
==> Options
--with-all
Installs Javadoc, examples, and source in addition to the binaries
Here, on the line 4 you can see the home path : /usr/local/Cellar/gradle/3.4
You can retrieve the path for GRADLE_HOME automatically using the following snippet in your .bashrc or .zshrc:
export GRADLE_HOME=$(brew info gradle | grep /usr/local/Cellar/gradle | awk '{print $1}')
This is handy when the path to Gradle's home changes, when Gradle is updated.
On Mojave (v10.14), Gradle v5.4, I had to append libexec after Gradle version for IntelliJ to work.
/usr/local/Cellar/gradle/5.4/libexec
I've gradle installed When using homebrew, below one failed with me, and kept telling undefined:
/usr/local/Cellar/gradle/<version>
The below symlink worked perfectly, and solved my issue:
/usr/local/opt/gradle/libexec
"brew info gradle" command not always give the installed path
br*ew info gradle
gradle: stable 5.6.3
Open-source build automation tool based on the Groovy and Kotlin DSL
https://www.gradle.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gradle.rb
==> Requirements
Required: java >= 1.8 ✔
==> Analytics
install: 29,106 (30 days), 144,607 (90 days), 611,211 (365 days)
install_on_request: 28,237 (30 days), 137,584 (90 days), 577,691 (365 days)
build_error: 0 (30 days)*
On Mojave, Gradle v6.6, I appended libexec after Gradle version for IntelliJ to work.
/usr/local/Cellar/gradle/5.4/libexec
My point isn't enough for commenting on flic's answer in the previous post.
If it happens to be in MacOS, the asterisk should be escaped as:
brew info gradle | sed -nE 's#^(/usr/local/Cellar/gradle/[^ ]+).+\*#\1#p'
or there will be sed: 1: "s#^(/usr/local/Cellar/g ...: RE error: repetition-operator operand invalid" error reported.
Related
Not a java dev touching java for the first time, can't get gradle to work.
I'm trying to install this extension for Ghidra. The readme says I should run:
GHIDRA_INSTALL_DIR=${GHIDRA_HOME} gradle
I've installed java 18 and gradle on a mac. When running the above, I get the following error:
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :copyDependencies NO-SOURCE
> Task :compileJava FAILED
/home/gradle/project/src/main/java/ghidra/app/plugin/core/analysis/eBPFSolanaAnalyzer.java:156: error: text blocks are not supported in -source 11
func.setComment("""
^
(use -source 15 or higher to enable text blocks)
1 error
FAILURE: Build failed with an exception.
Tried running out of docker too (thinking it was a problem with my installation):
docker run --rm -u gradle -e GHIDRA_INSTALL_DIR=/home/gradle/project/installed -v "$PWD":/home/gradle/project -w /home/gradle/project gradle gradle
But alas get the exact same error.
Why does gradle think I have Java 11 when in fact I have java 18? gradle -v gives me:
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 18.0.1.1 (Homebrew 18.0.1.1+0)
OS: Mac OS X 12.4 x86_64
This is probably total newb question but like I said I've never touched java:) Any help super appreciated.
The error means that the project has been configured to be compatible with Java 11, which is why you can't use features from newer versions (even if you run with a newer version).
While I don't know the Ghidra project, you can see from the build file in the extension that it applies a script from the base project:
apply from: new File(ghidraInstallDir).getCanonicalPath() + "/support/buildExtension.gradle"
Then, if you head over to the Ghidra project and find the extension file, you can see that it indeed configures the source and target version:
compileJava {
sourceCompatibility = ghidraProps.getProperty('application.java.compiler')
targetCompatibility = ghidraProps.getProperty('application.java.compiler')
dependsOn copyDependencies
}
These appear to come from the properties file located in Ghidra/application.properties:
application.name=Ghidra
application.version=10.2
application.release.name=DEV
application.layout.version=1
application.gradle.min=6.8
application.java.min=11
application.java.max=
application.java.compiler=11
So I would imaging that if you find this file in your local installation, you can change the application.java.compiler property to 18. Just be aware that Ghidra might not not actually support it - or it might work just fine; try it out :)
Hello everyone I am trying to create and run a react native app. I run
npx react-native init rn4 but when I run npm run android I have this error:
> Task :react-native-gradle-plugin:compileKotlin
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\ReactExtension.kt: (10, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\ReactExtension.kt: (119, 30): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\ReactExtension.kt: (135, 26): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\ReactExtension.kt: (155, 32): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\ReactExtension.kt: (161, 31): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\ReactExtension.kt: (169, 36): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\ReactPlugin.kt: (99, 48): 'reactRoot: DirectoryProperty' is deprecated. reactRoot was confusing and has been replace with rootto point to your root project and reactNativeDir to point to the folder of the react-native NPM package
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\TaskConfiguration.kt: (10, 37): 'ApplicationVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\TaskConfiguration.kt: (11, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\TaskConfiguration.kt: (12, 37): 'LibraryVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\TaskConfiguration.kt: (28, 51): 'BaseVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\TaskConfiguration.kt: (131, 12): 'ApplicationVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\TaskConfiguration.kt: (132, 12): 'LibraryVariant' is deprecated. Deprecated in Java
w: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\TaskConfiguration.kt: (250, 14): 'BaseVariant' is deprecated. Deprecated in Java
> Task :react-native-gradle-plugin:compileJava
6 actionable tasks: 6 executed
Note: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\java\com\facebook\react\codegen\generator\SchemaJsonParser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\emanu\App\rn4\android\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
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.
* Get more help at https://help.gradle.org
BUILD FAILED in 59s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\emanu\App\rn4\node_modules\react-native-gradle-plugin\src\main\java\com\facebook\react\codegen\generator\SchemaJsonParser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\emanu\App\rn4\android\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
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.
* Get more help at https://help.gradle.org
BUILD FAILED in 59s
at makeError (C:\Users\emanu\App\rn4\node_modules\execa\index.js:174:9)
at C:\Users\emanu\App\rn4\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\emanu\App\rn4\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\emanu\App\rn4\node_modules\#react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
I also run cd android && ./gradlew clean and the output is:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\emanu\App\rn4\android\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
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`.
This is the file in android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
and this is the output when I run ./gradlew --version
------------------------------------------------------------
Gradle 7.3.3
------------------------------------------------------------
Build time: 2021-12-22 12:37:54 UTC
Revision: 6f556c80f945dc54b50e0be633da6c62dbe8dc71
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 1.8.0_302 (Oracle Corporation 25.302-b08)
OS: Windows 10 10.0 amd64
I read similar posts but I haven't been able to fix it. With folders that I created some days ago I have no problem when I run the app.
Someone can help me please?
Very thanks!
If you are using React Native witch Chocolatey, you must update JDK version to 11.
In order to do the update, execute this in PowerShell (with admin privileges):
choco install -y openjdk11
After that, the first time (only the first time) you run npm android, you will get a lot of warnings, but the built of the project will work.
If you continue receiving an error, maybe you need to adjust the gradle version of your project to be compatible with the new JDK version.
You can achieve this by editing the file YOUR_PROJECT\android\gradle\wrapper\gradle-wrapper.properties
Update the version of distributionUrl to 7.4.2
I hope I have been helpful
The message is gone at last.
Before to that do the following [ iam using Mac]
Have JDK11 installed and HOME set
If you have any old version or have installed latest 18 and not as mentioned in the error. Then follow this URL to remove the the installation and ensure the path is set properly by following this [refer to the highest scored one]
Now to set the path follow this URL. Written by Arv
Now look for this file in android folder
android/.idea/compiler.xml and change the target set as "1.8" to "11"
run ./gradlew clean [run it twice..else same message will be visible]
I just installed jdk11 then run cd ./android/ && ./gradlew clean That works for me
openjdk11 v11.0.16.20220913 already installed.
node js version: v18.14.0
java version "19.0.2" 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
still has same problem.
----------solved----------
update java and change environment variables location of JAVA_HOME
Add this to gradle.properties
org.gradle.java.home=C:\\Program Files\\Java\\jdk-18.0.2.1
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Ultimately you need a newer version of Java to run this. There are many resources online to assist you with this. As it is recommending Java 11 I would stick with that. One place to get Java 11 for Windows is on the Oracle downloads site (as you currently have the Oracle build) but there are others related to OpenJDK too.
I was having this very same problem here. I tried MouTio's solution and updated the distributionUrl to 7.4.2 at Project-Name\android\gradle\wrapper\gradle-wrapper.properties but that still gave me this error here:
> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm targeta version.
1 actionable task: 1 executed
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-gradle-plugin:compileKotlin'.
Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRun
Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilat
However the error was fixed after running this choco install -y nodejs-lts openjdk11 with a command line using administration privileges.
and don't forget to run npm run android with a refreshed terminal.
Task :react-native-gradle-plugin:compileKotlin
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
Solution
Execute following commands
run cmd(Administrator) the past
choco install -y openjdk11
I have a version history that I'm trying to run a gradle build on and in my bash script I have
while read -r version
do
git checkout $version
gradle clean
gradle javadoc
...
done < version-history.log
which is trying to get the documentation for every tagged release of my code. The problem is that gradle runs a build once and then breaks out of the for loop. I tried encapsulating it in a function call, but it still manages to break out of the loop. Is this behavior intentional? How can I prevent it from doing this? My gradle version is
------------------------------------------------------------
Gradle 6.2.1
------------------------------------------------------------
Build time: 2020-03-01 17:25:20 UTC
Revision: <unknown>
Kotlin: 1.3.61
Groovy: 2.5.8
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 13.0.2 (Oracle Corporation 13.0.2+8)
OS: Linux 5.5.6-arch1-1 amd64
Gradle consumes the input for some reason, which is what causes this behavior. Appending </dev/null to the gradle call seems to fix the problem, try
while read -r version; do
git checkout $version
gradle clean </dev/null
done <version-history.log
When working with the latest Gradle version with Java 10 on Linux, it fails to identify version number of Java as 10 as valid Java version. How to fix this problem on Linux machines ? Log details of the error here
And here is the complete error report (N.B. Running gradle --version or gradle -v also gives the same output :
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '10'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
EDIT :
Output of gradle --stacktrace
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '10'.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
java.lang.IllegalArgumentException: Could not determine java version from '10'.
at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:70)
at org.gradle.api.JavaVersion.current(JavaVersion.java:80)
at org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(UnsupportedJavaRuntimeException.java:29)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:32)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Output of java --version
java 10 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
You need to upgrade Gradle. Version 4.5.1 and later definitely support Java 10.
If you think you have 4.5.1 or later installed, but gradle -version still won't run, it's possible that when you type gradle at the command line, it's still running an older version for some reason.
One common thing to do is alias gradle to ./gradlew, so that in the context of a Gradle project, you'll use the wrapper Gradle rather than the system Gradle. This is usually helpful, but in a situation like this, it backfires. You should be able to determine the installed system Gradle with which:
> which gradle
/usr/local/bin/gradle
> $(which gradle) -version
------------------------------------------------------------
Gradle 4.6
------------------------------------------------------------
Build time: 2018-02-28 13:36:36 UTC
Revision: 8fa6ce7945b640e6168488e4417f9bb96e4ab46c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 10.0.1 ("Oracle Corporation" 10.0.1+10)
OS: Mac OS X 10.13.4 x86_64
(I've elided some warnings about illegal reflective access, if you get those, don't worry about them.)
If $(which gradle) -version still won't run, you need to upgrade the system gradle. But if it does, to update the Gradle wrapper, you can edit your build.gradle --
task wrapper(type: Wrapper) {
gradleVersion = '4.6'
}
-- and then use the system Gradle to rerun the wrapper task:
> $(which gradle) wrapper
Starting a Gradle Daemon (subsequent builds will be faster)
BUILD SUCCESSFUL in 7s
1 actionable task: 1 executed
> ./gradlew -version
Downloading https://services.gradle.org/distributions/gradle-4.6-bin.zip
......................................................................
[etc.]
------------------------------------------------------------
Gradle 4.6
------------------------------------------------------------
Build time: 2018-02-28 13:36:36 UTC
Revision: 8fa6ce7945b640e6168488e4417f9bb96e4ab46c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 10.0.1 ("Oracle Corporation" 10.0.1+10)
OS: Mac OS X 10.13.4 x86_64
Take help of ppa and upgrade your gradle version , Ubuntu 17 comes with gradle sudo apt install gradle will install default gradle version.
to upgrade for java 10 need to run below command.
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt upgrade gradle
Guys I Found the problem in this case. I installed gradle from the official debian repositories which contained an outdated version of gradle which didn't support Java 10. On downloading and installing Gradle from the official site and soft linking it to the /usr/bin/gradle , it worked just fine. So the problem essentially was installing gradle from the debian repositories which are currently outdated.
I'm just starting out with Gradle and am almost certainly missing something obvious. My system has Java 7 installed as the default but I want all my Gradle projects to be using Java 8 by default. So, I create a ~/gradle.properties file and put the following in it:
$ cat ~/gradle.properties
org.gradle.java.home = /usr/lib/jvm/java-8-openjdk-amd64
But that doesn't appear to be honored. First, if I try to build my project I get:
Execution failed for task ':compileJava'.
> invalid source release: 1.8
Also, gradle --version gives:
$ gradle --version
------------------------------------------------------------
Gradle 1.5
------------------------------------------------------------
Gradle build time: Wednesday, October 8, 2014 8:21:39 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.4 compiled on October 7 2014
Ivy: non official version
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Linux 3.16.0-4-amd64 amd64
However, if I copy ~/gradle.properties to my project directory (the directory with the build.gradle file) or if I run JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 gradle assemble it works. So there's not a syntax error or anything in my gradle.properties file and the JDK path is correct. For some reason the properties file is ignored if it's in my home dir.
Note that I don't have a gradle.properties in my project directory and I also tried putting the file in ~/.gradle/gradle.properties. I also did a bunch of Google and StackOverflow search and just can't find an answer to this seemingly obvious question.
Long story short, gradle reads gradle.properties from ~/.gradle/gradle.properties not ~/gradle-properties and the docs are pretty clear about that. In short, I'm a knuckle-head.