Gradle Project Sync failed in Android Studio 2.3.1 - android

Upon reopening Android Studio after an improper shutdown, my gradle project sync failed and many errors like: "Failed to resolve: junit:junit:4.12" started showing up in the Event Log. Screenshot is given below.
I tried the following things to no avail:
Updated Android Studio to ver 2.3.1 and thus also the Gradle
I also had error for "Plugin Error: required plugin "xyz" is disabled" so i deselected all the plugins showing errors from settings and reselected them which removed the error.
Then i went to Files -> Invalidate caches/restart
What should i do?
UPDATE: After clicking on "Disable offline mode and sync project", this is what happened.

Here is a working solution..
Step 1)
In Android Studio go to File > Project Structure
there unticheck "Use Embedded JDK" and below choose your JDK location..
Step 2)
Go to file gradle > wrapper > gradle-wrapper-proparties
change gradle version to 3.5-all
Step 3)
close the project and reopen

From your first screenshot
Gradle is in offline mode, which means that it won't go to the network to resolve dependencies.
Go to Preferences > Gradle and uncheck "Offline work".
After that try cleaning the project and Re-running again?

What worked for me;
Go to Preferences > Gradle & uncheck "Offline work"
Goto File > Invalidate caches and restart.
The project would restart and can begin to install dependencies. Dont worry if it takes a time, that could be due to slow network. Just go and sip coffee while you wait ;)

Related

So when I started new project in android studio, where the build output shows "Connection refused: connect"

and also I can't see my design part of xml code. Kindly let me know what we can do,
I tried:
invalidating caches and restarting android studio.
build -> clean project -> build -> rebuild project.
In my case, I verified that in File > Settings> HTTP proxy, I had checked the "no proxy" option. Then I created an exception in my antivirus for Android Studio and deleted the lines of proxy configuration of my gradle.properties file. Finally, I clicked on Sync Project with gradle files and it worked.

Gradle sync failed: Cause: startup failed (Basic functionality not working)

It is my first time to use android studio V 3.1.3
when i finished installation and trying to build this error is shown
it said that "Basic functioality not working correctly such as building and debugging "
i do not known how to solve it
i use a local gradle distribution like this
Then press on sync project with gradles files
but this error is still shown.
It works well but after that this error is happened
any help
Thanks in advance.
I also have the same problems as you,Now I have solved it.
The following are the steps to be solved
Exit Android Studio.
Delete the .gradle folder eg: C:\Users{userName}}.gradle
Restart androidStudio and wait a moment.
Have you tried
Android studio -> File -> Invalidate Caches/Restart -> Invalidate and Restart
Deleting the .gradle folder was unsuccessfull for me.
Still waiting for another solution.
you should go to settings > build,execution,Deployment > build tool > gradle
and the change the user gradle home that to path of environment variable of JAVA-HOME Address
Like this
and then change gradle JDK to Embedded JDK it will solve your problem

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 project sync failed?

When I started up my project this morning it randomly gave me a message saying Gradle project sync failed. Basic Functionality(eg. editing, debugging) will not work properly. in Android Studio. I looked at other answers that people had put up for this problem but they haven't been working. I invalidated my chaches/restarted my project but no luck. I also deleted my .gradle folder from my project folder and still no luck. If any of you guys could help me that would be awesome! This didn't happen yesterday when I was working on the project or anything, I wonder why its happening now. Oh yea it also says this as a gradle message: Error:C:\Users\Dave\.gradle\caches\2.2.1\scripts\settings_ad4t0wp5ikihzl1y1o83b5sbw\SettingsScript\buildscript\cache.properties (The system cannot find the file specified) :
Thanks again for anyone who reads this/ can help!
There is a file - "cache.properties" that gradle creates for you, upon first time inception of any project. The path for this file is "~Home_Directory\.gradle\2.2.1\taskArtifacts". You may find this path in your home directory. So basically, this file - "cache.properties" is missing from the "taskArtifacts" folder.
One of the solution that worked for me is to copy file - "cache.properties" from any test project of yours to this project that's currently experiencing an issue.
Regards
I had to choose using the Default Gradle Wrapper instead of local.
<< SETTINGS -->/ BUILD TOOLS --> Gradle --> radio button switch... >>
It has helped me to fix the same problem.
I had experience similar sync failed problem with gradle based android project (in Android Studio 1.1.0). I solved this problem without deleting .gradle from my user directory,
steps I followed was
Go to File -> Settings -> Compiler(Gradle Based Android Project)
Change VM options to -Xmx512m -XX:MaxPermSize=512m.
Click Apply -> OK and then tap on Try Again option in sync failed message to clean build the project.
Works like charm!!
UPDATE - 1 : For Android Studio 1.3, Compiler option mentioned in above Step-1 is present inside tab Build, Execution, Deployment.
I had faced similar kind of problem earlier!
But don`t know after rebuild the project and cleaning it, it worked normally.
Invalidate dependency cache by running
gradle clean build --refresh-dependencies
from project root and then re-import your project. Worked for me once.
May be you have put Android Studio into offline mode. To fix it, go to Preferences -> Gradle and ensure that the "Offline work" checkbox is not checked.
Than do
File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio let it download all the Gradle stuff it needs
android studio 0.4.2: Gradle project sync failed error
Delete the folder C:\Users\.gradle and reopening the android studio solved my problem

"No cached version... available for offline mode."

I received an error message while building a new Hello World project in Android Studio:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'MyApplication2'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:0.9.1.
Required by:
:MyApplication2:unspecified
> No cached version of com.android.tools.build:gradle:0.9.1 available for offline mode.
BUILD FAILED
Android Studio version: 0.5.2
Gradle version: 0.9.1
I'm using a proxy connection to Internet.
With the new Android Studio 3.6 to toggle Gradle's offline mode go to View > Tool Windows > Gradle from the menu bar and toggle the value of Offline Mode that is near the top of the Gradle window.
Had the same error after updating Android Studio today. For me, it wasn't a matter of proxy settings:
Uncheck "Offline work" in Android Studio 0.6.0:
File->Settings->Gradle->Global Gradle Settings
or in OSX:
Preferences->Gradle->Global Gradle Setting
or in more recent versions:
File->Settings->Build, Execution, Deployment->Build tools->Gradle
Resync the project, for example by restarting the Android Studio
Once synced, you can check the option again to work offline.
(Only tested in Gradle version 0.11... and Android Studio version 0.6.0 Preview)
EDIT : Added paths for different versions/platforms (as mentioned by John Ballinger and The_Martian). Not yet verified.
Please follow below steps :
1.Open Your project.
2.Go to the Left side of the Gradle button.
3.Look at below image.
4.Click button above image show.
5.if this type of view you are not in offline mode.
6.Go to Build and rebuild the project.
All above point is work for me.
Just happened to me after upgrading to Android Studio 3.1. The Offline Work checkbox was unchecked, so no luck there.
I went to Settings > Build, Execution, Deployment > Compiler and the Command-line Options textfield contained --offline, so I just deleted that and everything worked.
I had same error...Please Uncheck the offline work in Settings.
File => Settings => Build, Execution, Deployment => Build Tools => Gradle => Offline Work
After Gradle Sync Finished, Please Restart Your Android Studio.
click on right second one image .
file -> invalidate and Restart .
It will work for me please try !!!
For mac, Uncheck Offline Work from Preference -> Build, Execution, Deployment -> Build Tools -> Gradle -> Global Gradle Settings
tip: cmd+, to open Preference via shortcut key
Since you mention you have a proxy connection I will tell you what worked for me:
I went to properties (as friedrich mentioned) ensuring the Offline Work was unchecked.
I opened up the gradle.properties file in the IDE and added my proxy settings. Here's a generic version:
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
Then at the top of the properties file in the IDE there was a "Try Again" link which I clicked. That did it.
New Solution (Due to the redoing of Android Studio)
File -> Settings -> Build, Execution, Deployment -> Compliler
In the line Command-line Options delete: --offline
In my case I get the same error title could not resolve all dependencies for configuration
However suberror said, it was due to a linting jar not loaded with its url given saying status 502 received, I ran the deployment command again, this time it succeeded.
For new UI, click the icon cloud to enable/disable offline mode.

Categories

Resources