最近两天在编译android项目时,突然报引用库错误的问题,好多maven的引用库不可用。废话不多说,直接说解决办法:
Caused by: org.gradle.api.resources.ResourceException: Unable to load Maven meta-data from https://maven.google.com/com/android/support/support-v4/maven-metadata.xml
解决思路,用国内的镜像,替换之前的镜像地址
- 打开AndroidStudio的gradle的编译文件build.gradle
-
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } }
- 改为阿里云的镜像
buildscript { repositories { jcenter{url 'https://maven.aliyun.com/repository/public'} // 阿里的镜像库,包含了mavencentral仓和jcenter仓 google{url 'https://maven.aliyun.com/repository/google'} } dependencies { classpath 'com.android.tools.build:gradle:3.5.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter{url 'https://maven.aliyun.com/repository/public'} google{url 'https://maven.aliyun.com/repository/google'} } }
- 可以正常编译通过,问题解决。
注意:本文归作者所有,未经作者允许,不得转载
原文地址: http://blog.wsmee.com/post/127
版权声明:非商用-非衍生-保持署名| Creative Commons BY-NC-ND 3.0