Android自动编译报错解决

作者: wencst 分类: javascript,linux,架构设计 发布时间: 2019-03-29 15:30 阅读: 230 次

环境

npm 5.6.0

node 8.9.4

gradle 5.1.1

问题一

执行npm run build:android报错

17:46:21 /platforms/android/gradlew: Command failed with exit code 1 Error output:
17:46:21 FAILURE: Build failed with an exception.
17:46:21 
17:46:21 * What went wrong:
17:46:21 Could not resolve all files for configuration ':app:releaseCompileClasspath'.
17:46:21 > Could not resolve com.android.support:support-annotations:27.+.
17:46:21   Required by:
17:46:21       project :app
17:46:21    > Could not resolve com.android.support:support-annotations:27.+.
17:46:21       > Failed to list versions for com.android.support:support-annotations.
17:46:21          > Unable to load Maven meta-data from https://maven.google.com/com/android/support/support-annotations/maven-metadata.xml.
17:46:21             > Could not HEAD 'https://maven.google.com/com/android/support/support-annotations/maven-metadata.xml'.
17:46:21                > dl.google.com: Name or service not known
17:46:21 > Could not resolve com.android.support:support-annotations:23.1.0.
17:46:21   Required by:
17:46:21       project :app > com.journeyapps:zxing-android-embedded:3.3.0 > com.android.support:support-v4:23.1.0
17:46:21    > Could not resolve com.android.support:support-annotations:23.1.0.
17:46:21       > Could not get resource 'https://maven.google.com/com/android/support/support-annotations/23.1.0/support-annotations-23.1.0.pom'.
17:46:21          > Could not GET 'https://maven.google.com/com/android/support/support-annotations/23.1.0/support-annotations-23.1.0.pom'.
17:46:21             > dl.google.com

而在服务内执行wget https://maven.google.com/com/android/support/support-annotations/maven-metadata.xml可以下载,说明本身网络没有问题。

 

问题解决:

1.删除~/.gradle文件夹

2.重新执行npm run build:android命令

使用shell调试,可以通过编译。

问题二

解决问题一时,使用的是shell执行,于是采用jenkins继续做自动集成操作,但是会报另外一个错误。

13:19:49 /platforms/android/gradlew: Command failed with exit code 1 Error output:
13:19:49 Note: Some input files use or override a deprecated API.
13:19:49 Note: Recompile with -Xlint:deprecation for details.
13:19:49 Note: Some input files use or override a deprecated API.
13:19:49 Note: Recompile with -Xlint:deprecation for details.
13:19:49 Note: Some input files use unchecked or unsafe operations.
13:19:49 Note: Recompile with -Xlint:unchecked for details.

问题解决:

1.删除~/.gradle文件夹

2.重新执行jenkins集成操作

解释

细心的可以发现,问题二和问题一解决的方案是一样的。

1.为什么wget可以下载,而使用gradle下载时却无法使用?

.gradle文件夹中,应该存储了应用的一些配置信息,每次执行时并不会重新更新文件夹中的配置文件。

2.为什么在解决问题一时重新下载依然会出现问题二中的问题?

问题依然在.gradle文件夹,在此文件夹中应该关联了当前执行用户的一些信息,不同的用户执行时,下载的组件版本号不同,所以会报出第二个错误。

如果文章对您有用,扫一下支付宝的红包,不胜感激!

kubernetes集群离线安装包, 仅需三步, HA安装:http://store.lameleg.com?referrer=wencst



Leave a Reply