You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PS D:\WorkSpace\PlayPen\DockerBuildApk> docker run -it soapgu/androiddockertest:v1.0 ./gradlew -version
/usr/bin/env: ‘sh\r’: No such file or directory
是吧了,这个报错是什么鬼
PS D:\WorkSpace\PlayPen\DockerBuildApk> docker run -it soapgu/androiddockertest:v1.0 ls /andriod
Dockerfile build.gradle gradle.properties gradlew.bat
app gradle gradlew settings.gradle
The problem's cause was that Git on Windows converted the line endings of gradlew from Unix style (LF) to Windows style (CRLF).
用notepad++转
PS D:\WorkSpace\PlayPen\DockerBuildApk> docker run -it soapgu/androiddockertest:v1.0 ./gradlew -version
Downloading https://services.gradle.org/distributions/gradle-7.0.2-bin.zip
..........10%...........20%...........30%..........40%...........50%...........60%..........70%...........80%...........90%..........100%
Welcome to Gradle 7.0.2!
Here are the highlights of this release:
- File system watching enabled by default
- Support for running with and building Java 16 projects
- Native support for Apple Silicon processors
- Dependency catalog feature preview
For more details see https://docs.gradle.org/7.0.2/release-notes.html
------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------
Build time: 2021-05-14 12:02:31 UTC
Revision: 1ef1b260d39daacbf9357f9d8594a8a743e2152e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.10 (Oracle Corporation 11.0.10+9)
OS: Linux 5.10.16.3-microsoft-standard-WSL2 amd64
成功
构建APK
docker run -it -v "D:\dockerbuilds:/andriod/app/build" soapgu/androiddockertest:v1.0 ./gradlew assembleDebug
PS D:\WorkSpace\PlayPen\DockerBuildApk> docker run -it -v "D:\dockerbuilds:/andriod/app/build" soapgu/androiddockertest:v1.0 ./gradlew assembleDebug
Downloading https://services.gradle.org/distributions/gradle-7.0.2-bin.zip
..........10%...........20%...........30%..........40%...........50%...........60%..........70%...........80%...........90%..........100%
Welcome to Gradle 7.0.2!
Here are the highlights of this release:
- File system watching enabled by default
- Support for running with and building Java 16 projects
- Native support for Apple Silicon processors
- Dependency catalog feature preview
For more details see https://docs.gradle.org/7.0.2/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/andriod/local.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.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 4m 34s
起因
原因是在上一篇里面,在coding自动化构建尝试升级Gradle版本到7,彻底失败。由于腾讯的主机把http的源配置进去了。然后在Gradle初始化环境的时候直接报错。
后续发工单找客户询问,经过几轮答非所问以后,客服建议用Docker来构建。不得不说起码最后一条还是一条很有启发性的建议。
过程
装Docker
首先我需要在本机安装Docker。过程不表。很久没玩了,windows docker的图形化界面做得好多了
找Docker基础镜像
gradle的环境需要是JAVA的环境。gradle wrapper是会自动安装的
所以从JRE镜像着手。
先本机查看 JAVA -version
openjdk:11.0.10-jdk-buster
找了一个和本机版本一致的
写一个安卓程序
DockerBuildApk
一个空的app,使用gradle版本7.0.2
gradle-wrapper.properties
为了保证代码文件时干净的,我用git clone后的文件夹作为Build根目录。不再用Android Studio打开
Dockerfile
docker build -t soapgu/androiddockertest:v1.0 .
先小试牛刀,跑个gradle version试试
是吧了,这个报错是什么鬼
问题文件确实存在的
还是StackOverflow比较厉害
Error with gradlew: /usr/bin/env: bash: No such file or directory
用notepad++转
成功
构建APK
docker run -it -v "D:\dockerbuilds:/andriod/app/build" soapgu/androiddockertest:v1.0 ./gradlew assembleDebug
本来想一鼓作气的。结果还是太乐观,Gradle在下完依赖后就构建失败了,缺了Android的SDK环境。
以前都是装Android Studio自动全配好的没有关注这一块(IDE也害人啊,离开就是残废啊)。Anyway,开局还行。
Dockfile还要重做,下一篇 我们来解决Android编译环境的问题
The text was updated successfully, but these errors were encountered: