ionic编译时运行命令
ionic cordova run android
此时出现无法获取com.android.support:support-annotations包的问题。
具体原因是gradle编译时下载对应包时无法访问到dl.google.com
:app:preDebugBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not resolve com.android.support:support-annotations:27.+.
Required by:
project :app
14 actionable tasks: 1 executed, 13 up-to-date
> Could not resolve com.android.support:support-annotations:27.+.
> Failed to list versions for com.android.support:support-annotations.
> Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/com/android/support/support-annotations/maven-metadata.xml.
> Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/support-annotations/maven-metadata.xml'.
> 这是在主机名解析时 ? 常出现的暂时错误,它意味着本地服务器没有从权威服务器上收到响应 ? (dl.google.com)
解决办法是改为aliyun.com 的源,具体做法是在build.gradle文件中添加源
maven{ url 'https://maven.aliyun.com/repository/google' }
完整配置如下:
image.png
网友评论