Update gradle version from command line using Android command line tools - android-studio

I have installed command-line tools (commandlinetools-linux-6200805_latest.zip) of Android Studio, and I want to update the gradle version to 6.2.
Any idea how I can do that?
In the UI I could just go to File -> Project structure.
Do I need the UI to do this?
tried to run: ./gradlew wrapper --gradle-version=6.2 --distribution-type=all
bash-4.2$ ./gradlew wrapper --gradle-version=6.2 --distribution-type=all
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/workspace/myapp/android/app/build.gradle' line: 3
* What went wrong:
An exception occurred applying plugin request [id: 'com.github.triplet.play', version: '2.7.5']
> Failed to apply plugin [class 'com.github.triplet.gradle.common.validation.RuntimeValidationPlugin']
> Gradle Play Publisher's minimum Gradle version is at least Gradle 6.2 and yours
is Gradle 5.6.4. Find the latest version at
https://github.com/gradle/gradle/releases/latest, then run
$ ./gradlew wrapper --gradle-version=$LATEST --distribution-type=ALL
* 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

If you are using the Gradle wrapper, you can simply run:
./gradlew wrapper --gradle-version=6.2
If you want to use a different distribution type than bin (default), you can add the distribution-type argument:
./gradlew wrapper --gradle-version=6.2 --distribution-type=all

Related

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

Which Gradle version shall be used for classpath after upgrading of android studio and plugins to 4.2.2?

After upgrading android studio from 4.1.3 to 4.2.2 and plugins, the line in build.gradle causes the error:
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2' //<<==which gradle version shall be used here?
}
The error is:
> Could not resolve all artifacts for configuration ':aliyun-oss-react-native:classpath'.
> Could not find com.android.tools.build:gradle:4.2.2.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.pom
Required by:
project :aliyun-oss-react-native
* 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.
What is the correct version of gradle used for classpath?
Go to your Project Structure settings and update gradle version to 6.7.1+version and let it download and then build project again.
For more information about Gradle and plugin versions check this out https://developer.android.com/studio/releases/gradle-plugin

WSL gradle pre-pending current directory to Android SDK path

I have set the terminal on Android Studio to use WSL, specifically the Ubuntu one. Running builds from the IDE provided buttons works fine for my project. I decided to start using the terminal more and would prefer to run the builds from there, so I tried running
./gradlew tasks
at the root of the project to test out the Gradle I had installed with sdkman in WSL, but I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/mnt/c/Users/Henry-PC/Desktop/DJ-Cloud/C:\Users\Henry-PC\AppData\Local\Android\Sdk' does not exist.
* 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 0s
Any ideas as to what is wrong with?
Just had this issue myself, I had a local.properties file that specified an incorrect directory.
After removing it entirely gradle is able to locate the Android SDK using the exported ANDROID_HOME environment variable

Android Gradle dependency compile doesn't work with Java 9

Friends,
I was trying to run gradle command (mentioned below) to resolve dependencies
gradlew -q dependencies app:dependencies --configuration compile
I am using JDK9 and and using gradle 4.4 but when run above mentioned command getting an error.
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':app'.
Failed to notify project evaluation listener.
javax/xml/bind/annotation/XmlSchema
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 20s
Please help me on this.
It is an Android SDK problem with Java 9: Failed to run sdkmanager --list (Android SDK) with Java 9

Gradle does not show any console output

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/

Resources