Gradle on macOS Hight Sierra - Java 9 - java

I update java to the lasted version e then I following this guide to install grade using Homebrew:
gradle installation guide
When the gradle installation is finished, I tried to launch gradre using the command: grade by command line but appear this error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
How can I fix this problem?

It is a Gradle bug has been fixed in version 4.2.1:
https://github.com/gradle/gradle/commit/d9c35cf9d74c102641fcfe0bb7bf622791a96caf

Related

Unsupported class file major version 61 Cordova Mac

So im on mac (Big sur), and i wish to build a Cordova app to android. I have java 17 installed, and gradle 7.1.1.
Im able to build the project on another windows computer just fine. (though i cannot rely on that for personal reasons)
But every time i try to build on mac, im confronted with following error:
FAILURE: Build failed with an exception.
* Where:
Settings file '/Users/me/app/cordovaProject/platforms/android/settings.gradle'
* What went wrong:
Could not compile settings file '/Users/me/app/cordovaProject/platforms/android/settings.gradle'.
> startup failed:
General error during conversion: Unsupported class file major version 61
(There is more to the error but its long. Will provide if needed.)
Answered by #JustInCoding, the solution for me was to install JDK 16, and then add org.gradle.java.home=your Jdk 16 path here in the gradle.properties file of my project.
Alternative solution that worked for me was to update gradle to 7.4.2.

Grails application not running after macOS upgrade

After upgrading my macOS to Big Sur, I have not been able to run my grails application. I keep getting this error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':server:compileGroovy'.
Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
I have reinstalled java, but still getting the same error.
Use this command to see java paths: /usr/libexec/java_home -V | grep jdk
Copying tools.jar in /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/ to /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/ solved the problem.

How to solve Gradle or Android Studio installation error on an Ionic app

I'm trying to upgrade my Ionic Android APP with new functionalities but get an error
Run $ ionic cordova build android --prod
cordova build android --release
Generating initial manifest for Ionic Deploy...
Ionic Deploy initial manifest successfully generated.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/albertosanmartinmartinez/Library/Android/sdk/tools/bin/platform-tools/emulator/build-tools/29.0.0-rc2/zipalign (recommended setting)
ANDROID_HOME=/Users/albertosanmartinmartinez/Library/Android/sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release exited with exit code 1.
Run $ brew info gradle
gradle: stable 6.8.1
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/HEAD/Formula/gradle.rb
License: Apache-2.0
==> Dependencies
Required: openjdk ✘
==> Analytics
install: 65,592 (30 days), 151,847 (90 days), 558,625 (365 days)
install-on-request: 64,753 (30 days), 150,185 (90 days), 546,096 (365 days)
build-error: 0 (30 days)
Reinstall $ brew install gradle and export it export PATH=$PATH:/usr/local/Cellar/gradle/gradle-7.0.2/bin
And we rerun $ ionic cordova build android --prodhrow new error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
No version of NDK matched the requested version 21.0.6113669. Versions available locally: 20.0.5594570
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 7s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
38 actionable tasks: 2 executed, 36 up-to-date
Command failed with exit code 1: /Users/.../platforms/android/gradlew cdvBuildDebug -b /Users/.../platforms/android/build.gradle
Anybody could help me please ?
Thanks in advance.

React Native - android wont compile after adding react-native-firebase

My react native android was compiling fine until I added react-native-firebase as per the docs (ios compiles fine).
React Native 0.63.2 and react-native-firebase 8.3.0 latest versions
and followed docs very carefully. OSX 10.15.6
Deleted/cleared/reinstalled gradle and android gradle/build dirs etc.
java JRE v8.202 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
java JRE v8.202 /Library/Java/JavaVirtualMachines
Note that JAVA_HOME path set to /Applications/AndroidStudio.app/Contents/jre/jd/Contents/Home
Error:
> Task :react-native-firebase_app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-firebase_app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
I'm using Mac Bigsur beta 4, and I have the same problem.
I tried uninstalling java by following the steps in this link:
https://www.java.com/en/download/help/mac_uninstall_java.xml
After that I checked the java version in terminal using: java -version.
The uninstall process didn't work. However, running react-native run-android now works.
Try this. It may work for you.
Note: If you tried uninstalling java, and running react-native run-android still doesn't work, add this to bash_profile and try again: export JAVA_HOME=/Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home
Ran source ~/.bash_profile to ensure JAVA_HOME path set to /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home and it compiled, yay.

How to use OpenJDK 11 when deploying to Heroku?

I am trying to deploy a Java application to Heroku targeting OpenJDK 11. I've added a system.properties file to the root of my application with the following content, as per Heroku instructions:
java.runtime.version=11
However, when I deploy, I get the following Gradle error:
Gradle app detected
-----> Installing JDK 1.8... done
-----> Building Gradle app...
-----> executing ./gradlew jar
Downloading https://services.gradle.org/distributions/gradle-4.10-all.zip
Welcome to Gradle 4.10!
[Gradle highlights]
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'.
How can I get Heroku to detect and use the correct Java version?
Gradle didn't officially support JDK 11 until version 5.0 (released November 26, 2018). Upgrading to that version or later should fix the issue.
See also this similar question about Java 9 support.

Categories