错误提示
* What went wrong:
A problem occurred evaluating project ':App'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
原因
因为项目升级了gradle 到7.0+
所以需要使用java11去运行gradle编译项目。
本地可以通过Android studio到gradle home 设置修改.
但jenkins需要修改相关配置才可以使用测试,并且不影响之前使用java 1.8的项目编译打包。
安装Java11
查看服务器的JDK版本和安装位置
alternatives --config java