If you need to pass sensitive information through the gradle action, and don't want the generated command to be printed before it is run, you can suppress that:

gradle(
# ...
print_command: false
)

You can also suppress printing the output generated by running the generated Gradle command:

gradle(
# ...
print_command_output: false
)

To pass any other CLI flags to gradle use:

gradle(
# ...
flags: "--exitcode --xml file.xml"
)

Delete the build directory, generated APKs and AABs

gradle(
task: "clean"
)

Parameters

Key

Description

Default

task

The gradle task you want to execute, e.g. assemble, bundle or test. For tasks such as assembleMyFlavorRelease you should use gradle(task: 'assemble', flavor: 'Myflavor', build_type: 'Release')

flavor

The flavor that you want the task for, e.g. MyFlavor. If you are running the assemble task in a multi-flavor project, and you rely on Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH] then you must specify a flavor here or else this value will be undefined

build_type

The build type that you want the task for, e.g. Release. Useful for some tasks such as assemble

flags

All parameter flags you want to pass to the gradle command, e.g. --exitcode --xml file.xml

project_dir

The root directory of the gradle project

.

gradle_path

The path to your gradlew. If you specify a relative path, it is assumed to be relative to the project_dir

properties

Gradle properties to be exposed to the gradle script

system_properties

Gradle system properties to be exposed to the gradle script

serial

Android serial, which device should be used for this command

''

print_command

Control whether the generated Gradle command is printed as output before running it (true/false)

true

print_command_output

Control whether the output produced by given Gradle command is printed while running (true/false)

true

* = default value is dependent on the user's system

Lane Variables

Actions can communicate with each other using a shared hash lane_context, that can be accessed in other actions, plugins or your lanes: lane_context[SharedValues:XYZ]. The gradle action generates the following Lane Variables:

SharedValue

Description

SharedValues::GRADLE_APK_OUTPUT_PATH

The path to the newly generated apk file. Undefined in a multi-variant assemble scenario

SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS

When running a multi-variant assemble, the array of signed apk's that were generated

Documentation

CLI

It is recommended to add the above action into your Fastfile, however sometimes you might want to run one-offs. To do so, you can run the following command from your terminal

fastlane run gradle

To pass parameters, make use of the : symbol, for example

fastlane run gradle parameter1:"value1" parameter2:"value2"

It's important to note that the CLI supports primitive types like integers, floats, booleans, and strings. Arrays can be passed as a comma delimited string (e.g. param:"1,2,3"). Hashes are not currently supported.

It is recommended to add all fastlane actions you use to your Fastfile.