Android Studio keeps resetting Gradle version when trying to install plugin - android

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.

Related

Upgraded gradle version Android Studio Ubuntu 20.04 LTS

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.

Android Studio 3.1 Stable. Build Successful but Can Not Resolve Error

I have updated to Android Studio 3.1 Stable Version today(27 March 2018).
I have an old project. With new studio version, it gets build successful and app gets installed on Emulator, but the on the IDE, Activity file shows
Can Not resolver Error
.
gradle file app module
Project level gradle file
I spent a long time on this yesterday after migrating from Android Studio 2.3 to 3.1. Tried everything from other answers to similar questions. Google's maven repository was correctly configured, tried invalidating caches and restarting, restarted the computer, etc.
The one thing that worked for me was closing Android Studio, deleting the .idea folder from my root folder and starting Android Studio again. Since I had everything checked into git before starting the upgrade I was able to do:
rm -rf .idea/
git checkout .idea
So I ended up with my original idea project files, but you should be fine if you can't revert to your checked in idea files. After reopening Android Studio it recreated some of the files I ended up deleting and everything worked again. Hope that helps others with the same problem.
This answer is old but basically suggests the same thing so I guess this problem keeps showing up. https://stackoverflow.com/a/21100896/791560
I was able to Fix:
https://developer.android.com/studio/build/dependencies.html#google-maven
From Android Studio 3.1, if we are working on Old projects built on 3.0 or lower, you need to add maven repository at top level build.gradle file. i.e., add google() under repositories of all projects.
For new projects, it gets added automatically.
App level, build tools version should be at min 27.0.3
Make sure compilesdk version and support library version are the same version level.

Android Studio - Plugin Too Old (Gradle)

Quite new to Android Dev, and I've been getting a strange error recently. I've searched online, and nothing seems to do the trick, so while I understand that this might be a duplicate question, no other previously asked question was able to offer me a working solution.
When I make a new project in Android Studio (version 2.2 Preview 1), I get bombarded with the error:
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "84c9986024dd3d7a4767dc5c38710ff1b96f1a21"
With two options: "Fix plugin version and sync project" which seems to do nothing. Upon clicking. And "Open File" which just opens the "build.gradle" file.
In my settings, I have Android Studio set to use the default gradle wrapper. I even set the distributionurl to the newest gradle version, but apparently even that is "too old"...
I have no idea what's causing this problem.
Another peculiar thing I've noticed is that in the project panel, it seems that my project doesnt look as it should.
The project in question looks like this:
Whereas, I understand that it should look more like this:
Again, no idea what's going on... I'm pretty new to Android Studio, but I'll do my best to answer any questions you may have.
While I believe the message may be because you have a 2.2 Preview build of Android Studio, it may want you to use a beta build of the Android Gradle Plugin.
Note: This is not related to the version of Gradle. The latest supported version of Gradle is 2.14.1, which you can check the Android Studio Release Notes, and also here.
From that first link, what I find most people don't understand.
The plugin runs independent of Android Studio so the plugin and the Gradle build system can be updated independently of Android Studio
Or Configuring your build, which explains why they are separated.
you can build your Android apps from within Android Studio, the command line on your machine, or on machines where Android Studio is not installed (such as continuous integration servers). If you are not using Android Studio, you can learn how to build and run your app from the command line. The output of the build is the same whether you are building a project from the command line, on a remote machine, or using Android Studio.

Android Studio 2.2 preview1 errors

So i'm trying to use Android Studio 2.2 preview-1 in Ubuntu 14.04 LTS.
I'm using gradle-2.10 and gradle-plugin 2.2.0-alpha1 along with openJDK-8.
compileSdkVersion 23
buildToolsVersion "23.0.3"
First the studio.sh didn't run and i found the solution to change #!/bin/sh to #!/bin/bash. Voila --it starts properly.
But in build.gradle files, warning is shown--
'dependencies' cannot be applied to '(groovy.lang.Closure)'
and its not finding imported class from library project(includes a jar only).
Please someone help me out.
The only fix that I found for this is, every time I open a project, I go to Settings>Build, Execution, Deployment>Gradle, change to "use local gradle distribution", click apply then click "use default gradle wrapper" and ok.
This should fix, but its quite annoying to do this everytime.
It Looks like a problem of version 2.10 of the wrapper version on gradle.
After reading around people's workaround like
"invalidate cache and restart"
delete .gradle file in the project and re-open it
etc etc
I just try for fun to install a standalone version of gradle since I'd always used only the wrapper version that cames with android studio.
And with it there is any error and any warning.
For anyone who wanna try (I'm a mac's user):
install gradle (by homebrew is fine and pretty easy) brew install gradle
tell to AS to use that one instead the wrapper version preference -> build, Execution, Deveployment -> Gradle -> use local gradle distribution
if you install it by homebrew like me the correct path will be: /usr/local/Cellar/gradle/x.yy/libexec
where x.yy it suppose to be 2.11 (that is the last version provide by brew even if the lastest version released is 2.13)
I've realised just now that the steps above doens't fix the definitly. Each time you re-open the project the problem came again and again.
It's annoying but changing betwen use of "wrapper"/"regular gradle" take the warning away.
But this means also that isn't a problem o the gradle as I'd assumed at the beginning.
...let's wait a permanent fix ^^
This issue is fixed in Android Studio 2.2 preview 2 (download from this page).
Disabled a couple of Groovy inspections that reported incorrect errors in build.gradle files
From the changelog.

Bug in just released 1.5?

Working on Linux.
Android Studio 1.4 told me that 1.5 is available in the stable channel;
I upgraded.
Afterward, 1.5 seems to be "looking" for Gradle 2.4; yet 2.8 seems to be what's actually installed.
More details:
After the upgrade, the Gradle sync failed on the project I opened.
Error message:
.../android-studio/gradle/gradle-2.4/lib/plugins/gradle-diagnostics-2.4.jar (No such file or directory)
But the version specific sub-directory within the gradle directory is gradle-2.8
The update procedure itself did not complain about any issues.
The update was done without any open projects; update was done from the main Studio panel.
After the update of Studio itself, via "Configure" from main panel went to "SDK Manager", then updated to newest compatible SDK.
Has anyone else had a similar problem?
Yes, there was a problem in this update.
Open file gradle-wrapper.properties in your project using Android view:
Just change the version 2.4 to 2.8:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Restart Android Studio.
Resolved - it seems some of the Gradle components were on the classpath for the JVM which studio itself uses; somehow the JVM didn't exit when Studio was to have re-started after the update. Once I bought that down and restarted Studio, the JVM and all, Studio 1.5 seems to be working just fine so far.
Sorry for the interruption to your regularly scheduled development!
There is definitely some issue with the upgrade as I also faced the same problem.
Although restarting the system (Mac) fixed it.

Categories

Resources