androidandroid-gradle-pluginintegration-testingandroid-testing

set targetSdk for androidTest apk


By default, the targetSdk of the test apk generated to run androidTest on a library is the minSdk.

Is there a way to explicitly set the targetSdk for the generated androidTest.apk to something different than the minSdk ?


Solution

  • The targetSdk can be set in testOptions block:

    android {
        testOptions {
            targetSdk = 34
        }
    }