gpt4 book ai didi

android - 如何使用 Gitlab CI/CD 生成签名发布 APK?

转载 作者:行者123 更新时间:2023-12-01 16:51:13 43 4
gpt4 key购买 nike

我正在尝试 GitLab 的 CI/CD,并正在研究如何生成签名的发布 APK。

我读过这篇文章here .

它提出了以下建议:

- ./gradlew assembleRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD

并将变量存储在 Gitlab CI/CD 变量中。

但是每次我运行管道时,它总是会导致这样的结果:

* What went wrong:
Execution failed for task ':app:packageRelease'.
> 1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException:
com.android.ide.common.signing.KeytoolException: Failed to read key key0 from store "/tmp/Lp7GrQLJ/0/XXXXX/sample-android-project/keystore": Keystore was tampered with, or password was incorrect

有人可以指导我吗?我可能做错了什么?

最佳答案

希望这会对您有所帮助。

image: openjdk:8-jdk

variables:
ANDROID_COMPILE_SDK: "27"
ANDROID_BUILD_TOOLS: "27.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_COMPILE_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
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- export GRADLE_USER_HOME="$(pwd)/.gradle"
- export ANDROID_HOME="$(pwd)/.android"
- mkdir -p "${ANDROID_HOME}/licenses"
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "${ANDROID_HOME}/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_HOME}/licenses/android-sdk-preview-license"
- echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "${ANDROID_HOME}/licenses/intel-android-extra-license"
#- ./gradlew --parallel --stacktrace --no-daemon build
- chmod +x ./gradlew

stages:
- build

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

此代码用于调试构建,请将脚本中的assembleDebug替换为assembleRelease

将其放在项目主文件夹中,名称为 .gitlab-ci.yml

关于android - 如何使用 Gitlab CI/CD 生成签名发布 APK?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56520730/

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