AndroidStudio - Gradle Refresh Failed

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

I was using the up to date version of android studio to build my app for android. The gradle wrapper set up the gradle installation and the project was build without errors.

Eventually I started getting one error each time I restarted.

Gradle: A problem occurred configuring project ':App'.

Could not resolve all dependencies for configuration ':App:classpath'. Could not resolve com.android.tools.build:gradle:0.5.+. Required by: App:App:unspecified

org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

The issue could be fixed by executing gradlew again and builds went fine. But after the 0.3 android studio update and android plugin update to 0.6.+ I can't even execute gradlew anymore without getting this error message.

I tried uninstalling android studio with all its configuration files, deleted the .gradle folders in the project and home directory and even the .m2 repository. I can't even start a new android project, it fails with the same error, so there should be no issue with my build.grade

buildscript {     repositories {         mavenCentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:0.6.+'     } } apply plugin: 'android'  repositories {     mavenCentral() }  android {     compileSdkVersion 18     buildToolsVersion "18.1.1"      defaultConfig {         minSdkVersion 15         targetSdkVersion 18     }      sourceSets {         main {             manifest.srcFile 'src/main/AndroidManifest.xml'             java.srcDirs = ['src/main/java']             res.srcDirs = ['src/main/res']         }     } }  dependencies {     compile 'com.android.support:support-v4:18.0.0'     compile 'org.jsoup:jsoup:1.7.2' } 

回答1:

I was able to solve the problem. I don't know what caused the bug, but its gone. Steps to fix:

  • Backup and delete existing project
  • Deinstalling android studio 0.3
  • Deleting .gradle/ and .androidstudio/ in user directory
  • Installing android studio 0.2.X
  • Patching android studio to 0.2.9
  • Reimporting code backup


回答2:

This is known issue http://tools.android.com/knownissues

The Android Gradle plugin 0.6.2 was published with incorrect dependencies. There isn't a way to delete it, so we have instead release 0.6.3 which fixes the problems. Just switch your version from 0.6.+ to 0.6.3, or run gradlew with --refresh-dependencies to force Gradle to look for an update.

dependencies {     classpath 'com.android.tools.build:gradle:0.6.+' } 

instead of

dependencies {     classpath 'com.android.tools.build:gradle:0.6.3' } 


回答3:

Make sure you have the latest version of Gradle as the latest Android Studio needed 1.8. Also make sure that you have downloaded updates through the Android SDK that is bundled in Studio. Tools-> Android-> SDK Manager

You will need the latest Android Support Library



回答4:

I was facing the same issue then I upgrade my react-native version :-

react-native upgrade 

its works fine for me now



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!