Gradle Project Sync failed in Android Studio 2.3.1

2019-03-06 18:12发布

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.

screenshot

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.

screenshot 2


3条回答
The star\"
2楼-- · 2019-03-06 18:38

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?

查看更多
手持菜刀,她持情操
3楼-- · 2019-03-06 18:40

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

查看更多
男人必须洒脱
4楼-- · 2019-03-06 18:42

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 ;)

查看更多
登录 后发表回答