Android Studio 3.6: Gradle "Offline Mode" is not working - android

I have an unstable internet connection so i want to work in Offline Mode.
I build my project with internet connection and then turn on the Offline Mode. I did not change anything, but the build fails telling me some dependency that i don't have in my Gradle files is not cached.
No cached version listing for com.google.android.gms:play-services-basement:[15.0.1,16.0.0) available for offline mode.
I even added this in my dependencies but it didn't work.
I guess that Gradle does not cache all the dependency tree but only the direct dependencies.
Is there a way to manually download these packages and copy to Gradle cache?
Thanks.

Related

Gradle doens't work offline in Android Studio 2021.2.1

I'm trying to use Android Studio offline because in the place I work, IT policy doesn't allow me to download .jar or .zip or some similar files though I can request the files which I want to download from IT team. I tried to create a hello world project offline but gradle didn't synchronised so I couldn't even run a simple project.
Here are the things I tried for running android studio offline;
I downloaded gradle version 7.2 complete build from official website,
Specified Gradle location using the menu File --> Settings --> Build, .. --> Gradle,
Choose version 7.2. for both Android Gradle plugin and Gradle versions in File --> Project Structure --> Project menu.
Added the zip of gradle version 7.2 to gradle-wrapper.properties as;
...
distributionUrl=file\:/gradle-7.2-all.zip
...
Switched to gradle offline mode
Downloaded offline-gmave-stable.zip from offline sources on the official website and set a gadle script according to https://gist.github.com/eladkarako/a4ffac49e21b02356246604917911f9c
At the end of all of the steps above, I still get connection errors.
Here is the error I got;
Could not resolve all artifacts for configuration ':classpath'.
Could not download gradle-7.2.0.jar (com.android.tools.build:gradle:7.2.0): No cached version available for offline mode
... (around 80 more jar files)
Possible solution:
Disable offline mode and rerun the build
It's third day and I couldn't even started to write a line of code. Could you please help me out?

Gradle - location for cached libraries in Windows

I am trying to develop a simple android application using Android Studio 3.1.1. While building I am getting a sync failed error from gradle. The bottom Build panel shows this error message.
Could not HEAD
'http://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.2.0/kotlin-stdlib-jre8-1.2.0.pom'.
Received status code 503 from server: Service Unavailable Enable
Gradle 'offline mode' and sync project
In my organization the access to this CDN is blocked. I tried by enabling the 'offline mode', now I am getting this error.
No cached version of org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0
available for offline mode. Disable Gradle 'offline mode' and sync
project
I downloaded the file kotlin-stdlib-jre8-1.2.0.pom, but I don't know where to put it so that Gradle can use it (as a cached version).
Is there any way to make this work when the CDN site is not accessible?
Or anyone know the windows folder where the gradle stores the cached libs?
Gradle supports an array of repository types. If you cannot use a Maven repository hosted by your organisation, there are other options available, like a flat directory repository or something else.
I would not recommend attempting to trick Gradle in believing it downloaded the dependencies. These are internal formats, subject to change from version to version.

Unable to sync gradle in android studio 3.0.1

Error:Failed to open zip file.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
(Re-download dependencies and sync project(Requires network)
Hello please help,
I am using android studio 3.0.1. I have active internet connection then also this problem arrive. I also did it manually i.e.in gradle folder i manuaaly added that distribution gradle-4.1-all.zip.
But it didn't worked!! please help.
Clean your project. Delete .idea and .grade folder from your project folder. Now build your project.
If still fails, try running gradlew from Terminal in Android Studio. Still fails, check your network connection and/or proxy settings.

Gradle sync failed: Could not determine artifacts for com.android.support:recyclerview-v7:24.0.0

I am unable to sync my build.gradle the below error is showing
Gradle sync failed: Could not determine artifacts for
com.android.support:recyclerview-v7:24.0.0: No cached version
available for offline mode
To solve this use this way.
Uncheck Offline work in Android Studio
go this way
File->Settings->Build, Execution, Deployment->Build tools->Gradle.
Resync the project, by restarting the Android Studio.
Once synced, you can check the option again to work offline.
Setting->Build,Execution,Deployment->Build tools->gradle, disable offline work, click ok then.

Gradle is failing on syncing my project in the new Android Studio 2.0

I have just upgraded (i.e., installed a full new version) my Android Studio from 1.5 to 2.0. The upgrade seemed to go smoothly, but I am having trouble with my project when I open it, when Gradle is syncing my project.
After Gradle sync runs for a couple of minutes I get this error:
Failed to sync Gradle project MyProject
Unknown host 'jcenter.bintray.com'. You may need to adjust the proxy settings in Gradle.
Error: Enable Gradle "offline mode' and sync project
Learn about configuring HTTP proxies in Gradle
So, I click on the link that says:
Enable Gradle "offline mode' and sync project
Then Gradle spins for a second or two, and I now have this message:
Failed to sync Gradle project MyProject
Error: No cached version of com.android.tools.build:gradle:1.3.0 available for offline mode.
Disable Gradle 'offline mode' and sync project
So, I click on this link:
Disable Gradle 'offline mode' and sync project
And I am back to my first error again.
The machine I am working on is 100% off line. It does not have, nor will it ever have any kind of network connection whatsoever. I figure I need to disable some kind of check that requires the internet, but I am not sure what. Is this fixable, or do I have to downgrade back to Android Studio 1.5?
UPDATE
I am also getting this error message:
Gradle sync failed: Unknown host 'services.gradle.org'. You may need to adjust the proxy settings in Gradle.
Ok, I fixed my issue so I wanted to post how I did it in case somebody else runs into this situation.
I was googling around and found a statement regarding working offline with Android Studio that read:
You can, however you won't be able to use any Gradle dependency. Gradle search into the repositories for dependencies using internet, so if you're completely unable to work online. Try not to include anything in the Gradle files, if you do, you'll have to sync it and it'll fail. Bascially just don't touch Gradle files and you'll be good to go.
So, I looked at my gradle files, specifically the build.gradle for the Project (not for the Module). Once there, I noticed a line:
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
So, I replaced 1.3.0 with 2.0.0 and the project built just fine.
I hope this helps somebody else in the future. Good luck.
I got same problem when I downloaded "BackboneExampleApp" source code from guithub Click Here For Code. I have done following process by watching settings of my old projects and found these errors. I resolved both errors, run my app and got errors to upgrade project and finally when I updated then no more problems exist. Just see pictures for help.
build.gradle (Project:BackboneExampleApp-master)-->
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
I also come with the same problem in my application. I have Done invalidate caches/restart then the problem is resolved.
I had the same problem as yours. Fortunately, I managed to solve it. You need to go to File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle. You need to change the Gradle Home. Mine was "C:/Program Files/Android/Android Studio/gradle/gradle-2.08" and it said the path is invalid. So, just recheck your path in your file explorer and change it. I changed mine to "C:/Program Files/Android/Android Studio/gradle/gradle-2.10".
I had a similar problem. I was trying to build one of the media samples. I tried to use gradle 2.0.0 as you suggested but it didn't work. Got me on the right track though. gradle 2.1.0, along with deactivating offline mode got it to work.
For me it was a connection issue, that I have checked my connection is working in the same second I have enabled and disabled offline Gradle, then Android Studio download the needed files
NB: My Connection was disconnecting and reconnecting many times, so i figured out that this error was caused by the connection specially it was not the same time it takes when trying to sync my Gradle
For those have issues with error message: Learn to configure HTTP settings, below is the solution that worked for me. Am using Android studio 2.3.3:
Go to http://developer.android.com/studio/intro/studio-config.html
Step 1: Follow the instructions on: Set up Android studio proxy.
Step 2: Follow the instructions on : Android plugin for gradle HTTP proxy setting. You will see proxy settings under : # project wide gradle settings, copy the code there and paste it into the empty space in gradle properties file which is under the build gradle in Android studio. Make sure you are connected to internet while on this process. Wait until the the error disappears.
Step 3: you may see another message pop up stating: some folders may have been missing syn now. Just click on syn now.
I hope this help, thanks all.
I was fallen the same trouble, you mentioned. But I solved it myself. I connected my pc to the internet and rebulit the project using PROJECT>>REBUILT PROJECT.
Then some downloads could be seen below with the name of jcenter.......
THEN THE PROBLEM SOLVED...😃
Gradle build became successful..
I faced the same issue. Make sure that you have made an entry in path in environment variable for gradle
C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin
After disable offline mode and setting the path in environment variables, the issue was fixed and Gradle was build cleanly.
It seems there are multiple reasons for this issue. I fixed it by changing the "Gradle version" and "Android plugin version".
It might be helpful to someone. Go to File->Project Structure. Select Project and update your gradle and android plugin versions.
I also came with the same problem in my application..The application Gradle version is 2.3.3 .I just update the Gradle to 3.0.1 .and the problem is solved.
My problem was different from all answers; gradle distribution url was wrong..
It might be the problem that distributionUrl can be wrong in gradle-wrapper.properties file.

Categories

Resources