gpt4 book ai didi

android - 使用 Gitlab CI 生成 Android 构建

转载 作者:IT老高 更新时间:2023-10-28 23:00:33 24 4
gpt4 key购买 nike

我刚刚安装了 Gitlab 作为我的项目的存储库,我想利用他们的 Gitlab CI 系统。我想在每次提交后自动生成分发和调试 Apk。我用谷歌搜索,但没有找到任何教程或类似案例。如果有人能以某种方式指导我,那就太好了。

谢谢!

最佳答案

我刚刚在 how to setup Android builds in Gitlab CI using shared runners 上写了一篇博文.

最快的方法是有一个 .gitlab-ci.yml 包含以下内容:

image: openjdk:8-jdk

variables:
ANDROID_TARGET_SDK: "24"
ANDROID_BUILD_TOOLS: "24.0.0"
ANDROID_SDK_TOOLS: "24.4.1"

before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz
- tar --extract --gzip --file=android-sdk.tgz
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_TARGET_SDK}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
- export ANDROID_HOME=$PWD/android-sdk-linux
- chmod +x ./gradlew

build:
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/

首先使用 Java 8 Docker 镜像,然后在构建运行之前下载并安装 Android SDK 的必要位。我的帖子还详细介绍了如何将其构建到 Docker 镜像中并将其托管在 Gitlab 本身上。

希望对您有所帮助!

更新 - 2017 年 4 月 10 日

早在 16 年 11 月,我就为 Gitlab 官方博客写了一篇关于在 Gitlab CI 中设置 Android 构建的规范博客文章。包括有关如何运行测试等的详细信息。链接在这里。

https://about.gitlab.com/2016/11/30/setting-up-gitlab-ci-for-android-projects/

关于android - 使用 Gitlab CI 生成 Android 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24942751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com