Could not resolve all files for configuration ‘:app:androidApis‘

 我在第一次使用AndroidStudio时,编译项目遇到了此问题

Could not resolve all files for configuration ‘:app:androidApis’.

Failed to transform file ‘android.jar’ to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform

Cannot create mockable android.jar

invalid entry compressed size (expected 17451 but got 17576 bytes)

 

后来上网查找了很多解决法案,试了很多方法,最后解决了,这是我的解决方案,在此分享给大家,希望能给你们带来帮助。

在出现上述问题的时候,打开sdk manager

Could not resolve all files for configuration ‘:app:androidApis‘

下载一个低版本的API(这里我自己下的是api27)

Could not resolve all files for configuration ‘:app:androidApis‘

下载完成后,接着打开file->pioject structure ,在modules的app中把sdk version 改为下载的那个版本

Could not resolve all files for configuration ‘:app:androidApis‘

然后跟着下面图片修改,将项目app -> build.gradle中的sdk version改成下载的版本(只改数字,其他不用动)

Could not resolve all files for configuration ‘:app:androidApis‘

在gradle scripts中的build.gradle(也就是另一个build.gradle)添加以下代码,如果已有,就覆盖修改

buildscript {
    
    repositories {
        google()
        jcenter()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    }
allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    }
}

最后点击file – > invalidate caches /restart 进行清除缓存和重启,就好了,这是我第一次使用时遇到这个问题的解决方案了

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/8e1087155f.html