Skip to content

Commit 720b0a1

Browse files
Bernard Chauerictanggoogle
authored andcommitted
Workaround mnc preview sdk minSdkVersion and targetSdkVersion restrictions
so that the same apk can be installed on both M and L code to disable M features on L is already there http://cs/android/vendor/google/tools/TestDPC/app/src/main/java/com/google/android/testdpc/policy/PolicyManagementFragment.java&l=415 Bug: 21832415 Change-Id: I888a2aa79f7a74652d6585a4228612d1b6c62cec
1 parent 5247945 commit 720b0a1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

app/build.gradle

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66

77
defaultConfig {
88
applicationId "com.google.android.testdpc"
9-
minSdkVersion 'MNC'
10-
targetSdkVersion 'MNC'
9+
minSdkVersion 21
10+
targetSdkVersion 21
1111
versionCode 1
1212
versionName "1.0"
1313
}
@@ -21,6 +21,23 @@ android {
2121
sourceCompatibility JavaVersion.VERSION_1_7
2222
targetCompatibility JavaVersion.VERSION_1_7
2323
}
24+
25+
/* TODO: remove once release version of M sdk is released */
26+
def minVersion = defaultConfig.getMinSdkVersion().getApiString()
27+
def targetVersion = defaultConfig.getTargetSdkVersion().getApiString()
28+
applicationVariants.all { variant ->
29+
variant.outputs.each { output ->
30+
output.processManifest.doLast {
31+
def manifestOutFile = output.processManifest.manifestOutputFile
32+
def newFileContents = manifestOutFile.getText('UTF-8').
33+
replace('android:minSdkVersion="MNC"',
34+
'android:minSdkVersion="' + minVersion + '"')
35+
newFileContents = newFileContents.replace('android:targetSdkVersion="MNC"',
36+
'android:targetSdkVersion="' + targetVersion + '"')
37+
manifestOutFile.write(newFileContents, 'UTF-8')
38+
}
39+
}
40+
}
2441
}
2542

2643
dependencies {

0 commit comments

Comments
 (0)