3

Currently there are two apk files that I need so that I can run a test on AWS device farm:

  1. app.apk
  2. app-androidTest.apk

app.apk is generated fine as I intended

$ ./aapt list -a .../apk/app-debug.apk | grep SdkVersion

A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
A: android:targetSdkVersion(0x01010270)=(type 0x10)0x19
A: android:maxSdkVersion(0x01010271)=(type 0x10)0x19

but app-androidTest.apk has a sdk version fixed to 0x19(25) no matter what I do

$ ./aapt list -a .../apk/app-debug-androidTest.apk | grep SdkVersion

A: android:minSdkVersion(0x0101020c)=(type 0x10)0x19
A: android:targetSdkVersion(0x01010270)=(type 0x10)0x19

I have my gradle setting as below:

compileSdkVersion 25
buildToolsVersion '25.0.2'
lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}
defaultConfig {
    applicationId "com.thisclicks.appdataroom"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode versCode as Integer
    versionName versName
    multiDexEnabled true
    testInstrumentationRunner}

I need a testing apk with minSdk 0x10, targetSdk 0x19. but it doesn't follow my gradle setting and get overridden by something else. however there are no gradle or androidManifest that interferes. My guess is that when I generate the testing apk, I do it by manually running on an emulator with API 25. It automatically generates the apk. Is this a possible reason that my testing apk is tied to the sdk version of 25 (min and target)? If then do you know how can resolve this?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
mblueblue
  • 31
  • 2

2 Answers2

0

Only solution I found for this yet. Is to run the tests with emulator that has lower API level than your target SDK.

If I run test with my android 8.0.1 device it will set the testcase.apk minsdk to same as target sdk i.e 26. But if I run the tests in android studio with api level 21 emulator it will build the test case apk with minsdk 18

Hope this helps you.

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69
wpj
  • 206
  • 2
  • 14
0

assembleAndroidTest command also builds the APK correctly, when no devices attached.

wpj
  • 206
  • 2
  • 14