Upgraded gradle version Android Studio Ubuntu 20.04 LTS - android

I just upgraded my android studio version and gradle version to the new one as AS suggest me. But now every time I try to build my project gradle has this error:
Could not create parent directory for lock file /opt/android-studio/plugins/gradle/wrapper/dists/gradle-7.5-bin/f1w0cc9nuo0eivz97x2xlu9sv/gradle-7.5-bin.zip.lck
Of course it worked perfectly fine before upgrade and I didn't change anything manually in path or version used.
I know it's a permission error, but I tried to build it as sudo, it downloaded and installed correctly but once I went back to a normal user process, it can't recognize that gradle has already been installed on my system. I have this error
The specified Gradle distribution 'https://services.gradle.org/distributions/gradle-7.5-bin.zip' does not exist.
knowing I didn't change anything in my path or used version while swapping between sudo and normal user.
Does anyone know how to force AS to detect and use already installed gradle version?

One option will be to open Android Studio's settings:
Build, Excecution, Deployment > Build Tools > Gradle
and from there you can specify whether to use Gradle from gradle-wrapper.properties file or from a specified location. The latter should fit your needs.
Tested with AS Chipmunk and Dolphin.

Related

Cordova - Android - Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0

Making an android project with cordova, when I try to making a build, it failed with this issue:
execution failed for task ':app:compileDebugJavaWithJavac'
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0
These are my versions:
Cordova: 10.0.0
Android Platform: 10.1.2
Gradle: 7.1.1
I am absolutely sure that Gradle is installed when I install the Android platform (and it is out of my control) and that everything was working fine until 1 month ago ... and I have not changed anything
How I can fix this issue???
Have I to update Gradle? How?
Have I to update the project? How?
it's very strange ... and frustrating
Updating gradle solves the problem.
There are different ways to update the gradle, as explained in their official website: https://gradle.org/install/
Assuming that you are a windows user:
Downloading binary files of gradle and extracting the folder to the directory "c:/gradle" is enough.
Download binary files of gradle for the next version
Update path of gradle in PATH variable in your computer
You should define another variable as follows:
Variable name should be the same and its value should be the same with the one you use. While creating your cordova environment, this url is being used.
Save and restart your IDE's or CLI windows
test it out like ´gradle -v´ and you should see the active version of gradle in your system.
Be prepared to the new problems in your cordova environment because you have a upgraded gradle now
To fix the issue, I've reverted to cordova-android version 9.1.0. I've no idea, as of now, why cordova-android version 10 points to gradle, which as of now isn't possible to download...

Android Studio keeps resetting Gradle version when trying to install plugin

I'm fairly new to using android studio, and I can't seem to wrap my head around what i'm doing wrong.
I'm currently trying to install the Ping Plugin from Cordova, now everytime I try and install it I get the error message
Minimum supported Gradle version is 4.4. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/sam/Development/Apps/ghost/gradle/wrapper/gradle-wrapper.properties to gradle-4.4-all.zip
So from here I go to File > Project Structure > Project and change the Gradle version to 4.4 and the Android Plugin version to 3.1.1. I then let android studios build and do what it needs to do.
From here I check the gradle-wrapper.properties file and can confirm it says 4.4-all.zip.
I then try and reinstall the plugin, it then throws the same error, so I check my gradle-wrapper.properties file and it resets itself back to 4.1!
Am I doing something stupid?
Again i'm very new to Android Studios, so apologies if i've missed anything.
Incase it helps, some extra details are
OS - macOS High Sierra 10.13.4
Homebrew - Global machine Gradle version 4.7
Android OS - 6.0.1
Cordova - 8.0.0
EDIT
Something else I have noticed, If I go into the .gradle folder in my application, and remove the 4.1 folder and try to install the plugin, it automatically recreates the 4.1 folder and uses it?
Also i've now noticed it has this behaviour every time I run any cordova command, including cordova build android
For anyone else experiencing this behaviour, once I found out that it was any cordova command that was causing the gradle to reset, It was easy to find the answer.
Answer
Basically there is a distributionUrl located inside the GradleBuilder.js file that kept on resetting my gradle back to 4.1. This needed to be changed to 4.4 and the build and plugins worked straight away!
"Moral of this particular story, for me anyway, don't update Android Studio for no good reason" - This should be made the 11th Commandment. I was able to fix this issue by deleting the /platform/android folder and re-installing it making sure not to click on any "highly recommend" upgrade options.
In addition to the answer above and listed in the path below,
Cordova build changes distributionUrl in gradle-wrapper.properties file
I found that on Android Studio 3.1.2, it is necessary to update not just GradleBuilder.js as per all previous advice, but also StudioBuilder.js.
Just to be clear, both files are in the same directory:
$PROJECT_ROOT/platforms/android/cordova/lib/builders/
and the text to be changed in this instance is
'https\://services.gradle.org/distributions/gradle-4.1-all.zip' to
'https\://services.gradle.org/distributions/gradle-4.4-all.zip'
Moral of this particular story, for me anyway, don't update Android Studio for no good reason, as it'll take up 3 hours of your day fixing sh*t. Wait till Cordova has been upgraded to suit before even thinking about it.

Do Android build tools require to download Gradle for every new project?

I have a couple of Android project samples I am going to build via the commandline using ./gradlew build on Linux. Whenever I enter this command a message says "Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip". I think I already have the latest gradle under my Android Studio installation path. Why does this have to download gradle every time? Can I specify gradle as an environment variable e.g. GRADLE_HOME so that all projects can use it?
What you have in your Android Studio installation path is not significant when using the Gradle Wrapper (gradlew). It downloads the exact version of Gradle that the current build is designed for and tested with if no other build downloaded it already. The downloaded distributions are stored under ~/.gradle/wrapper/dists/. So as long as you don't delete that folder and you have multiple builds that use the same gradle distribution in the wrapper configuration, that distribution will only be downloaded by the first build you execute. The others will use the already present distribution.

Can't get Terminal Emulator for Android to build in Android Studio

I'm trying to build Terminal Emulator for Android. I'm running Android Studio 1.4 in Kubuntu 15.04. I also tried building it in Ubuntu 14.04 LTS with the same results. The project requires the latest Android NDK, SDK 22, and SDK 11 which I've downloaded and configured in Android Studio. My system gradle version is 2.8, and Android Studio has downloaded some other versions internally. I'm using jdk1.8.0_65, which is set to JAVA_HOME and configured in Android Studio. I've built several other projects with my configured Android Studio and only seem to have a problem with this project. I need to use this project as a base for an app I'm developing.
I end up with same error, posted below, no matter what route I take to fix it in Android Studio. This is generally what I've done to try and get the project to work. I open up the project unmodified in Android Studio. I click Build >> Rebuild Project. I get an error telling me ndk implementation is deprecated. I add a file gradle.properties to the root directory of the project with the line android.useDeprecatedNdk=true and rebuild. It gives me an error: Task 'generateDebugTestSources' not found in project. I execute Sync Project With Gradle Files to resolve it. Then I end up with the following error and can't get past it.
Gradle 'Android-Terminal-Emulator-master' project refresh failed
Error:exception during working with external system:
or
Gradle sync failed: exception during working with external system:
Consult IDE log for more details (Help | Show Log)
idea.log
Things I've done to try and get the project to build:
Modify all of the project's build.gradle files to use the experimental plugin
Use different versions of Android Studio
Switch from openjdk to Oracle's jdk
Upgrade gradle to the latest version
Set gradle to default wrapper (default) and also set gradle to different versions
invalidate cache, remove ~/.gradle, and rebuild project
Make sure PATH includes the gradle and jdk bin directories and is in ~/.bashrc, ~/.profile, and ~/.zshrc
remove proguard from libtermexec library
reboot computer
I should note that the project builds without issue on the command line. I'd really like to get the project to build in Android Studio for development.
Install Arch and run Android Studio there.
I decided to try building Terminal Emulator on my Arch server, so I installed a xfce (Desktop Environment) and Android-Studio through pacman. I followed the same general path to get things setup, and the app built without issue.
The idea log Android Studio generated for the failed build on Windows and Ubuntu didn't point to any clear problem, even with --stacktrace enabled with gradle. I'm not going to waste my time figuring out why gradle doesn't want to build apps in Ubuntu or Windows.

Android Studio starts downloading gradle

I have downloaded android studio and sdk and everything required but when I start a new project studio starts downloading gradle which is already downloaded with android studio. If I try to stop that download, it can't be stopped, I need to shutdown my laptop.
Please tell me why this happens!
And if I import any project then it shows a message that gradle build failed and tells me to install build tools API Level 7 which NOBODY uses now a days. What's wrong with this studio??
I am using Ubuntu 14.04, .gradle directory of my home folder has files of more than 300 Mb I don't understand what this android studio keeps downloading.
Please help me fixing this problem
That is normal one time download of maven gradle dependencies and packages. However it usually takes a long time to download and build. Not sure what are the reasons for this.
Android studio contains gradle essentials, but for some reasons that is insufficient to run command line tools.
There is a workaround to skip this download by adding gradle repo directory to android studio settings (Configure --> Settings --> Gradle). You have to manually add GRADLE_HOME to the system PATH variable according to your operating system. Run gradle-v in command line to confirm everything works right.

Categories

Resources