Skip to content

Commit 8c61584

Browse files
committed
Hack to modify xxxSdVersion for building pre-N apk against preview SDK
Modify the minSdkVersion and targetSdkVersion in generated manifest Change-Id: I8470693c0a316a3ad12a196bdd8f1c257da9e6c8
1 parent b610333 commit 8c61584

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

app/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,35 @@ android {
5050

5151
productFlavors {
5252
standard {
53+
minSdkVersion 21
5354
targetSdkVersion 23
5455
}
5556

5657
N {
58+
minSdkVersion 'N'
5759
targetSdkVersion 'N'
5860
}
5961
}
6062

63+
/* TODO: remove once release version of N sdk is released */
64+
applicationVariants.all { variant ->
65+
variant.outputs.each { output ->
66+
output.processManifest.doLast {
67+
// minSdkVersion and targetSdkVersion are overridden if we build against preview
68+
// SDK, let us override them again here.
69+
minSdkVersion = variant.getMergedFlavor().minSdkVersion.getApiString();
70+
targetSdkVersion = variant.getMergedFlavor().targetSdkVersion.getApiString();
71+
72+
def manifestOutFile = output.processManifest.manifestOutputFile
73+
def newFileContents = manifestOutFile.getText('UTF-8').
74+
replace('android:minSdkVersion="N"',
75+
'android:minSdkVersion="' + minSdkVersion + '"')
76+
newFileContents = newFileContents.replace('android:targetSdkVersion="N"',
77+
'android:targetSdkVersion="' + targetSdkVersion + '"')
78+
manifestOutFile.write(newFileContents, 'UTF-8')
79+
}
80+
}
81+
}
6182
}
6283

6384
dependencies {

0 commit comments

Comments
 (0)