From 720b0a11d711e4e8b196b3068cead1fb74b406d6 Mon Sep 17 00:00:00 2001 From: Bernard Chau Date: Fri, 12 Jun 2015 17:20:41 +0800 Subject: [PATCH] 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 --- app/build.gradle | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e7f006b3..fa033469 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { defaultConfig { applicationId "com.google.android.testdpc" - minSdkVersion 'MNC' - targetSdkVersion 'MNC' + minSdkVersion 21 + targetSdkVersion 21 versionCode 1 versionName "1.0" } @@ -21,6 +21,23 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } + + /* TODO: remove once release version of M sdk is released */ + def minVersion = defaultConfig.getMinSdkVersion().getApiString() + def targetVersion = defaultConfig.getTargetSdkVersion().getApiString() + applicationVariants.all { variant -> + variant.outputs.each { output -> + output.processManifest.doLast { + def manifestOutFile = output.processManifest.manifestOutputFile + def newFileContents = manifestOutFile.getText('UTF-8'). + replace('android:minSdkVersion="MNC"', + 'android:minSdkVersion="' + minVersion + '"') + newFileContents = newFileContents.replace('android:targetSdkVersion="MNC"', + 'android:targetSdkVersion="' + targetVersion + '"') + manifestOutFile.write(newFileContents, 'UTF-8') + } + } + } } dependencies {