Why Gradle is downloading every time? - android-studio

Whenever I open a fresh project, Gradle is downloaded each time. Actually it is one shot, otherwise any changes in gradle.properties.
I have downloaded latest version of Gradle and set environmental variables.
So my question is any way to change this downloading each time to get system level Gradle?
Note: I have set Gradle file location in Android studio. But it is not working, I think.
Thanks in advance

Related

How can I save All Android Studio Configuration & Settings?

It happened to me too many times that I did some changes in the Android Studio environment (for example update Gradle version, update Build-Tools, installing new components or plugins that I needed in order to solve some errors that I got) and after that, previous versions that I saved & that where 100% compiled/Built successfully, are suddenly giving me errors.
I want to be able to take a backup of my project that was built OK just a few days or weeks ago, and make it compile again without errors. For that I need to restore the Android Studio environment to the same configuration that it was when I compiled that backup on the first time.
So, how can I save & restore Android Studio's configuration/Settings?
Hope that the question is clear.
Thanks very much.

Can i delete my gradle folders?

Can i delete the older versions of the gradle folder versions such as 2.0, 3.3 and just keep the latest version or are all of them required by Android Studio?? click to see all the gradle folders under wrapper
Yes, it is simply a cache.
You can always delete the downloaded Gradle versions, as the Gradle wrapper will redownload them if required.
However, if you don't necessarily need space on your disk, you can also keep them, so that they can be reused whenever a Gradle project with the specific version is executed. This way, you may save the time to redownload.

gradle Unexpected lock protocol found in lock file. Expected 3, found 0

getting "Unexpected lock protocol found in lock file. Expected 3, found 0" error when trying to debug even after following this link and deleting the .gradle folder
current gradle version is 4.4 and android studio 3.1.2
I found another solution which i think is much better.
Go to project structure Ctrl + Alt + Shift + S and select Project from left menu if it is not already selected.
Select latest Android Gradle Plugin Version
Select Gradle Version to the latest stable one.
Select Apply.
List item
P.S It is better to Update gradle to latest stable version.
Hope this helps
This error normally occurs when your system mistakenly shut down and the project is building. Here is the solution:
close the project
delete the project from Android Studio list
Close Android Studio
delete the .gradle folder from the root of your project
Run Android Studio again
Open existing Android Studio project
Or check here
Simplest & most easy way to solve this issue
This error generally occurs when we update our android studio version or make changes in previous projects. I don't know why but it comes randomly. I follow many ways to solve this but ill figure out the easiest way to tackle this.
First, go to the android studio, then click on File.
Second, go to the project structure & Click the project tab.
Third, most imp step -> check the (Gradle Version) of yours (In my case my previous is 6.5 & latest one is 6.8.1) if it is the previous one, not the latest, then select the latest one..... remember not to select (beta) select only stable release. & (Apply) then (OK) -> your project start downloading files & I hope your problem gets solved. Just like mine. Check Images for better understanding.
Main Solution : The most effective solution in my case was change distributionUrl (go to gradle-wrapper.properties) to latest version like below.
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
Second Solution : invalid cache and restart.
Third Solution : Clean Project Rebuild Project.
To solve this issue it took me few steps:
-go to C:\Users[username] and delete the .gradle folder
-go to the project folder and delete the .gradle folder
-inside the project folder execute gradlew.bat
Don't use different Gradle versions for building a project!
Make sure that gradlew build and gradle build use the same version.

Why is android studio downloading components again?

I changed my account from admin to other. why is android studio downloading components again. I downloaded everything previously... How to proceed?
You possibly used the default location for android sdk. You can move it, while the studio is turned off. The next time you start it, it will ask you to tell him where the new location is.
Also gradle wrapper downloads some other files, like gradle itsels. That is also stored for each user, but don't worry about this

INSTALL_FAILED_DEXOPT zip archive does not include classes.dex

I've been struggling with this problem for 2 days. I can't debug my application on my android device using Android Studio.
This is the error I get:
[INSTALL_FAILED_DEXOPT]
When I look at the logs, it says "zip archive does not include classes.dex"
So the problem is that classes.dex isn't being built into the APK. This is true since the file size of my APK is now around 1MB whereas it used to be around 1.3MB.
I have tried everything, but I have no idea why classes.dex isn't being built into my APK. Any help is greatly appreciated.
Joaquin
Try cleaning your build, and build the app again.. Make sure you've added the activities to the Android manifest. Once you get the apk use 7zip to view apk and check if there is classes.dex or use native zip viewer if on Linux. And if nothing still works try synchronizing the build files so that gradle can detect non ide changes.
I just tried disabling my antivirus (Avast), cleaning and rebuilding the app and then restarting Android Studio.
Those steps worked and I can now debug my application on my android device again.
Note that classes.dex is only generated if your project contains Java classes. So if you are using the NDK in combination with native activities, there won't be no Java code at all and therefore no classes.dex. In that case, you have to set the hasCode attribute in the manifest to false because otherwise dexopt will be looking for it.
http://developer.android.com/guide/topics/manifest/application-element.html#code

Resources