Gradle is failing on syncing my project in the new

2019-01-09 17:22发布

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.

10条回答
在下西门庆
2楼-- · 2019-01-09 17:55

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.

查看更多
forever°为你锁心
3楼-- · 2019-01-09 17:55

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.

查看更多
神经病院院长
4楼-- · 2019-01-09 17:56

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.

查看更多
The star\"
5楼-- · 2019-01-09 17:57

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.

查看更多
时光不老,我们不散
6楼-- · 2019-01-09 17:59

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".

查看更多
聊天终结者
7楼-- · 2019-01-09 18:00

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.

查看更多
登录 后发表回答