Android 杰弗 CI/CD

Android Jetifier CI/CD

尝试在 CI/CD 环境中使用 Jetifier,具体来说,我使用的是 bitrise,但真正的问题是我想自动化部署过程。在 AndroidX 之前这工作正常,现在我需要一种通过命令行为整个应用程序使用 jetifier 的方法。我已经进入了使用 exclude 摆脱所有可以想象的依赖项的兔子洞,但是 enableJetifier=true 什么都不做,除非你从 Android Studio 构建。我是否遗漏了一个 gradle 插件,我在过去 2 周的谷歌搜索中没有找到它?或者这是一个未解决的问题?

我 运行 遇到了与 Jenkins/Fastlane 相同的问题。由于 gradle.properties 出于安全原因不应在存储库中 enableJetifier=true 环境变量将对任务不可见。

解决方案是将 properties 添加到 gradle 快速通道任务中:

  desc "Create a release build"
  lane :release do
    remove_apk
    gradle(
        task: "assembleRelease",
        properties: {
            "android.enableJetifier" => "true",
            "android.useAndroidX" => "true"
        }
    )
  end

我不熟悉 bitrise,但是这个 link 可能有助于为 bitrise 设置 settings/environment variables

In general the solutions (might be others too, if anyone have any additional note just let us know!):

  1. Use a secondary repository to store your secrets in, and git clone that with a Script step for example (if you’d want to do this please make sure that the same SSH key can be used for both repos! 11)

  2. Use App Env Vars or Secret Env Vars on bitrise.io 37 - you can find these in the Workflow Editor (Workflow tab of your app on bitrise.io 37). The variables you define here are regular environment variables, so you can use them any way you like, e.g. with a Script step, writing into a file.

  3. Use the Generic File Storage 63 feature of bitrise.io 37, upload your file(s) and download it using the File Downloader or ZIP resource archive downloader step.

These are just the highlights of the main solutions of course, there are other possible ways if you’re more adventurous, e.g. store the file encrypted in your repository, store the encryption key in an App Env Var or Secret Env Var on bitrise.io 37 and decrypt the file during the build.

同时检查:https://devcenter.bitrise.io/builds/env-vars-secret-env-vars/

郑重声明,这是我在 Bitrise 上启用 Jetifier 所做的工作:

  1. 转到工作流编辑器 > 代码签名选项卡
  2. 将您的 gradle.properties 文件上传到通用文件存储空间
  3. 返回工作流编辑器,在"Android lint"(或"Android build")步骤
  4. 之前插入一个"File downloader"步骤
  5. 将文件下载器的源设置为您在第2步中刚刚上传的新文件
  6. 将目标设置为 $PROJECT_LOCATION/gradle.properties
  7. 保存
  8. 构建和 享受!