-
-
Save dbachelder/9534270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.android.build.gradle.AppPlugin | |
import com.android.build.gradle.LibraryPlugin | |
subprojects { | |
// This is an annoying hack to get around the fact that the Gradle plugin does not support | |
// having libraries with different minSdkVersions. Play Services has a min version of 9 (Gingerbread) | |
// but Android Maps Utils supports 8 (Froyo) still | |
it.afterEvaluate { subProject -> | |
// is this a library or an app? | |
if(subProject.plugins.hasPlugin(AppPlugin.class) || subProject.plugins.hasPlugin(LibraryPlugin.class)) { | |
// variants are accessed in different ways for each.. | |
def variants = subProject.plugins.hasPlugin(AppPlugin.class) ? android.applicationVariants : android.libraryVariants | |
variants.all{ variant -> | |
variant.processManifest.doFirst { | |
File manifestFile = file("${buildDir}/exploded-bundles/ComGoogleMapsAndroidAndroidMapsUtils03.aar/AndroidManifest.xml") | |
if (manifestFile.exists()) { | |
println("Replacing minSdkVersion in Android Maps Utils in sub-project $subProject") | |
String content = manifestFile.getText('UTF-8') | |
content = content.replaceAll(/minSdkVersion="8"/, 'minSdkVersion=\"9\"') | |
manifestFile.write(content, 'UTF-8') | |
println(content) | |
} | |
} | |
} | |
} | |
} | |
} |
Put it in the top level build.gradle
I get an error message: "Could not find property 'AppPlugin' on project ':XXXXX'. "
I fix it replacing AppPlugin.class by "android" and LibraryPlugin.class by "android-library"
..
..
if(subProject.plugins.hasPlugin("android") || subProject.plugins.hasPlugin("android-library")) {
// variants are accessed in different ways for each..
def variants = subProject.plugins.hasPlugin("android") ? android.applicationVariants : android.libraryVariants
..
..
@ignaclogs sorry, i didn't see this earlier!
you just need some imports:
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin
But your way seems fine too... probably less brittle.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This version is for a gradle project with multiple android apps and/or library projects.