Search code examples
androidinstrumented-testandroid-studio-flamingo

App is uninstalled after playing instrumented tests since migration to Giraffe


I have used Flamingo for some time, and after playing an Espresso test, the app was still installed.

Then I upgraded to Giraffe, and now, after playing an Espresso test, the app is uninstalled. I did not changed my project, just upgraded Android studio. Any idea of what can be done so that the app is not uninstalled in this case?

Note: after running the app itself, it is not uninstalled.


Solution

  • The issue tracker says:

    "Added android.injected.androidTest.leaveApksInstalledAfterRun field in gradle.properties. Setting this field to false indicates that in the current project, all the APKs installed during test will be uninstalled after test finishes. Setting it to true means that AGP will leave the test APKs untouched after test. Default is false"

    "This will be available starting in AGP 8.3.0-alpha07"

    "The fixes for this issue are now also available in:

    Android Studio Hedgehog | 2023.1.1 RC 1 Android Gradle Plugin 8.2.0-rc01"

    Confirmed upgrading to Android Studio Hedgehog, upgrading to Gradle 8.2 and adding the following to my gradle.properties file resulted in the app remaining on the emulator after running tests.

    android.injected.androidTest.leaveApksInstalledAfterRun=true