fastlane

How to specify output .apk file path when using fastlane gradle?


I have different product flavors of my app and I build them with fastlane. This is my fastfile:

default_platform(:android)

platform :android do

  desc "Release apk with different urls"
  lane :release do
    gradle(
      task: "assemble",
      build_type: "release",
      flavor: "flavorname",
      print_command: true,
      properties: {
        "android.injected.signing.store.file" => "Key.jks",
        "android.injected.signing.store.password" => "KeyPass",
        "android.injected.signing.key.alias" => "KeyAlias",
        "android.injected.signing.key.password" => "KeyPass"
      }
    )

  end

end

The problem is apk files are created in project directory.

(projectname/app/build/outputs/apk/flavorname/release/app-flavorname-release.apk)

How to move this apk files to my Desktop automatically?


Solution

  • It doesn't seem that gradle has an option to specify the output. What I suggest you is to add a command line just after the gradle is done to move this .apk to the Desktop or wherever you want.

    sh "mv ../app/build/outputs/apk/release/app-release.apk path/to/Desktop"