Android Studio报错集锦(三)

一、依赖包无法正常下载 / 一致卡在"Download maven-metadata.xml" / 无法获取pom文件

项目的build.gradle

buildscript {
    repositories {
        maven{ url 'https://maven.aliyun.com/repository/google'} 
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} 
        maven{ url 'https://maven.aliyun.com/repository/public'} 
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}

        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        maven{ url "https://maven.google.com"}
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}

allprojects {
    repositories {
        maven{ url 'https://maven.aliyun.com/repository/google'} 
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} 
        maven{ url 'https://maven.aliyun.com/repository/public'} 
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}

        maven{ url 'https://maven.aliyun.com/repository/public/' }
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        maven{ url "https://maven.google.com"}
        jcenter()
        google()
    }
}

若还一致卡在"Download maven-metadata.xml"

1.要检查一下项目的build.gradle文件的maven地址是否有不可用的,比如

maven { url "http://101.201.39.57:8082/nexus/content/groups/public" }。

检查方法:浏览器输入“http://101.201.39.57:8082/nexus/content/groups/public”,看是否可以访问。若不可以,屏蔽它。

2.可能和第三方包使用的support包的版本有关系,在工程中build.gradle文件中添加:

configurations.all {//强制所有的第三方包使用指定版本的support包
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.1'
            }
        }
    }
}

Android Studio引用远程依赖包时下载不了jar包的解决方法

Android Studio Download maven-metadata.xml 下载中一直卡住

国内maven库镜像(阿里云)

升级Gradle Plugin为4.4后,Could not resolve all files for configuration ':classpath'.

Android studio 的repositories配置

二、Default Activity Not Found 问题总结

三、Compilation is not supported for following modules: xxxxxx, app.Unfortunately you can 't have non-Gradle Java modules and Android-Gradle modules in one project.

1-结束项目
2-关闭Android工作室
3-删除.IDEA目录
4-删除所有.iml文件
5-打开android studio并导入该项目

四、resource android:attr/fontVariationSettings not found

五、强制所有的第三方包使用指定版本的support包

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.1'
            }
        }
    }
}

六、依赖的aar包中报错:Type `org.apache.http.util.EncodingUtils` was not found
因为Android6.0 org.apache.http.util.EncodingUtils等相关类被移除。
gradlew版本不能太高,经测试4.4ok

Gradle和其插件的对应关系

你可能感兴趣的:(AndroidStudio)