AndroidStudio升级报错Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve c

近日升级AS到3.2.1版本,新建工程时报错:


 

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
Open File
Show Details
 


错误原因:项目默认配置了gradle 4.6版本,镜像服务器错误(mirrors.neusoft.edu.cn 没有提供下载服务)导致无法下载gradle-4.6-all.zip,无法完成编译。

 

解决方法1:降低gradle版本

  • 打开 gradle/wrapper/gradle-wrapper.properties,修改gradle版本为本地已下载版本。如gradle-4.4-all.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

记得同时修改build.gradle内容:3.1.0

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

解决方法2:更新到最新版本

  • 不使用镜像地址下载gradle-4.6-all.zip,因为镜像地址连接失败,所以把它拿掉。
    找到
    /Users/lvxiangan/.gradle文件夹,打开gradle.properties

     

    ## For more details on how to configure your build environment visit
    # http://www.gradle.org/docs/current/userguide/build_environment.html
    #
    # Specifies the JVM arguments used for the daemon process.
    # The setting is particularly useful for tweaking memory settings.
    # Default value: -Xmx1024m -XX:MaxPermSize=256m
    # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    #
    # When configured, Gradle will run in incubating parallel mode.
    # This option should only be used with decoupled projects. More details, visit
    # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    # org.gradle.parallel=true
    #Thu Dec 06 23:52:05 CST 2018
    使用#号注释掉以下4行
    systemProp.http.proxyHost=mirrors.neusoft.edu.cn
    systemProp.http.proxyPort=80
    systemProp.https.proxyHost=mirrors.neusoft.edu.cn
    systemProp.https.proxyPort=80

    或者删除整个文件。重启AS,可以看到正在重新下载gradle-4.6-all.zip

     
  • 如果上一步下载很慢,可以通过网盘或迅雷下载到本地,从本地直接加载。

    下载好复制到 /Users/lvxiangan/.gradle/wrapper/dists/gradle-4.6-all/bcst21l2brirad8k2ben1letg 文件夹下,然后重启AS。

    注意:bcst21l2brirad8k2ben1letg 文件夹名称是由系统随机产生,请不要尝试修改它。

最后来一张成功编译图,晚安!

 

 

 

 

  • 16
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
It seems like you are encountering a dependency resolution issue in your Android project. The error message "Could not resolve all files for configuration ':app:androidApis'" indicates that some required files could not be found or resolved. Here are some steps you can try to resolve this issue: 1. Check your internet connection: Make sure you have a stable internet connection as the build process requires downloading dependencies from remote repositories. 2. Refresh dependencies: Try refreshing the dependencies by running the following command in your project directory: ``` ./gradlew clean build --refresh-dependencies ``` This will force Gradle to download the latest dependencies for your project. 3. Check repository URLs: Ensure that the repository URLs specified in your project's `build.gradle` file are correct and accessible. You can verify this by opening the URLs in a web browser. 4. Update Gradle and Android Studio: Make sure you are using the latest version of Gradle that is compatible with your Android Studio version. Update Gradle by modifying the `distributionUrl` in the `gradle-wrapper.properties` file located in the `gradle/wrapper` directory of your project. For example, if you are using Gradle 6.7, modify the `distributionUrl` to: ``` distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip ``` Then sync your project with Gradle files. 5. Invalidate caches and restart: Go to "File" -> "Invalidate Caches / Restart" in Android Studio to clear any cached files that might be causing conflicts. If none of the above steps resolve the issue, please provide more details about your project setup, such as the version of Android Studio, Gradle, and any relevant dependencies you are using.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值