ionic编译时无法获取android.annotations包解决办法

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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容