Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coding持续集成吐血升级Gradle之旅 #67

Open
soapgu opened this issue Jul 31, 2021 · 0 comments
Open

coding持续集成吐血升级Gradle之旅 #67

soapgu opened this issue Jul 31, 2021 · 0 comments
Labels
IDE Good for newcomers problem problem or trouble 安卓 安卓

Comments

@soapgu
Copy link
Owner

soapgu commented Jul 31, 2021

  • 源起

    昨天李若冠发现Android Studio推了新的更新,4.2.2升级到了 Arctic Fox全新的版本,安卓的 Gradle 插件也从4.2.2 建议升级到7.0.0,Gradle版本也从6.7.1建议升级到7.0.2。
    都是IDE直接操作无需特别操作啥。本地编译构建没有问题。程序运行也正常。本着激进的能用新版本尽量使用新版本的原则,版本推送coding。一次很平常的操作

  • 自动化持续集成失败

coding通知我们的构建APK失败了
图片
我们现在构建任务设置为推送自动构建,反正不花钱。如果有问题还可以提前发现。

我以为是一次偶发构建错误,以前也有过。我直接点了手动构建。很不幸,也失败了,看来不是偶然事件了
图片
必须要介入处理了

首先回滚安卓的 Gradle 插件从7.0.0滚回4.2.2
图片
看来是整个Gradle版本也需要回滚
图片
这回构建成功了,至少底线就是不能升级。。。

  • 查找问题根源

回过来分析下可能出现问题的点
1 用到了本地引用,写法上被禁止了?
2 人脸库引用了很多老库,拖累造成升级失败?
3 再加点gradle的日志辅助下判断

由于没有明确的思路,需要逐步排查,专门切了分支专门做持续集成测试

  1. 删掉了本地引用相关的项目
  2. 删掉了人脸库
    构建还都是失败了

只能从Gradle输出的信息入手去分析了
加了--info --debug --stacktrace
所有的信息都指向这句话

[2021-07-30 22:05:10] > Could not resolve all dependencies for configuration ':classpath'.

[2021-07-30 22:05:10]    > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://mirrors.tencentyun.com/nexus/repository/maven-public/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.0.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 

第一句比较通用,没具体参考价值,就是引用解析失败
第二句就有点迷了,前面也有看到但是没引起太多注意。maven http://mirrors.tencentyun.com/nexus/repository/maven-public/ 这个仓库我又没用过,而且指明了是没有用https,不符合安全。
既然所有证据都指向这里,那一定是这里有问题。而且最不能理解的是我本地使用gradle命令执行一点问题都没有,一开始还怀疑是windows的环境和coding主机是Linux环境差异有影响。后来想想不对啊,gradle不是JAVA的程序嘛,JAVA的招牌就是一次编译处处运行,不同平台不应该有差异。
经过这样一推理,那么只能是环境配置有问题了,项目的配置全部是git上复制一样的。那有问题就是所有项目都不能7.0.2编译了。再推一个空的Android项目上去,名字就叫TestG7,使用Gradle7.0.2持续集成试试。
图片
果然报错都一模一样。
再把TestG7改为6.7.1,编译通过了,基本上问题形成了闭环。

仔细看日志会发现6.7.1编译是有警告的

[2021-07-30 23:24:17] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

[2021-07-30 23:24:17] Use '--warning-mode all' to show the individual deprecation warnings.

[2021-07-30 23:24:17] See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings

把--warning-mode all 加上看具体信息

 Using insecure protocols with repositories has been deprecated. 
This is scheduled to be removed in Gradle 7.0. 
Switch Maven repository 'maven(http://mirrors.tencentyun.com/nexus/repository/maven-public/)' to a secure protocol (like HTTPS) or allow insecure protocols. 
See https://docs.gradle.org/6.7.1/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.

实锤了。那基本就是环境把这个仓库带进来了,这样就可以解释为啥我本地构建是没问题的了

  • 结局

看来升级Gradle的版本的事情只能先放一下了。一次吐血的升级尝试。原来错误的根本原因就在眼前,就是灯下黑。升级太赶时髦了,网上同类问题似乎也没有。看来让子弹飞一会了吧。
后续已经开工单给客服了,待后续吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE Good for newcomers problem problem or trouble 安卓 安卓
Projects
None yet
Development

No branches or pull requests

1 participant