How To Test Android App Bundle

Google has released the Android App Bundle feature. An .aab file is generated by the feature, which we are supposed to upload to the Google Play Store. We can manage the .aab file via CLI using the official bundletool which is available from bundletool. The guide also help us to understand the feature.

We can get distributed apk files from the .aab file via the CLI. Using the generated files, we can test against the release module. Since Appium 1.9.2, you can Appium tests against an .apks file using UiAutomator2 driver. 1 and 2 are PRs for the feature.

How to run tests

  1. Export bundletool.jar in your path
    • Appium looks for bundletool.jar in your local environemnt. Make sure you can find the path with which 'bundletool.jar'. If you can't find it, please set the path correctly.
  2. Generate the .apks file from the .aab file
    • The .aab is available over Android Studio 3.2
    • You must sign correctly when you generate .apks from .aab. This step requires data signing. bash $ java -jar apks/bundletool-all-0.6.0.jar build-apks \ --bundle apks/release/release/app.aab \ # A generated aab file --output apks/AppBundleSample.apks \ # An apks file you'd like to out put to --ks apks/sign \ # Signing keystore --ks-key-alias key0 \ # Alias of the keytstore --ks-pass pass:kazucocoa \ # Password of the keystore --overwrite # Overwrite any existing apks files
  3. Use the path to the .apks file as your app capability. ```ruby desired_capability = caps: { platformName: :android, automationName: 'uiautomator2', platformVersion: '8.1', deviceName: 'Android Emulator', app: "path/to/your.apks", # This line is important fullReset: true, ... }

    core = ::Appium::Core.for(desired_capability) driver = core.start_driver ```

You can find another way to get test APKs in https://developer.android.com/guide/app-bundle/

Tips

Test with different languages

Set fullReset: true if you would like to test against the app using different languages' resources.

Appium only installs the minimum set of resources, following the behavior of the appbundle feature. For example, if a device's language is set of English, Appium will only install the en resource. The installed apk will have no Japanese resources.

In orfer to force re-install with a different set of language resources, specify fullreset: true

An example project