androidandroidxbitriseandroid-jetifier

Android Jetifier CI/CD


Trying to use the Jetifier in a CI/CD environment, for me specifically I'm using bitrise, but the real issue is I want to automate the deployment process. Prior to AndroidX this worked fine, now I need a way to use the jetifier for the whole app through the command line. I've gone down the rabbit hole of using exclude to get rid of every dependency imaginable, however enableJetifier=true does nothing, unless you build from Android Studio. Am I missing a gradle plugin that I haven't found over the past 2 weeks of googling? Or is this an unsolved problem?


Solution

  • I ran into the same problem with Jenkins/Fastlane. Since gradle.properties should not be in the repository for security reasons enableJetifier=true environment variable will not be visible to the task.

    The solution was to add properties into the gradle Fastlane task:

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

    I am not familiar with bitrise, however this link may help setting the settings/environment variables for bitrise.

    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.

    Also check: https://devcenter.bitrise.io/builds/env-vars-secret-env-vars/