Skip to content

Instantly share code, notes, and snippets.

@goldierox
Created March 13, 2014 17:59
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save goldierox/9533466 to your computer and use it in GitHub Desktop.
Save goldierox/9533466 to your computer and use it in GitHub Desktop.
android.applicationVariants.all{ variant ->
// 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
variant.processManifest.doFirst {
File manifestFile = file("${buildDir}/exploded-bundles/ComGoogleMapsAndroidAndroidMapsUtils03.aar/AndroidManifest.xml")
if (manifestFile.exists()) {
println("Replacing minSdkVersion in Android Maps Utils")
String content = manifestFile.getText('UTF-8')
content = content.replaceAll(/minSdkVersion="8"/, 'minSdkVersion=\"9\"')
manifestFile.write(content, 'UTF-8')
println(content)
}
}
}
@dbachelder
Copy link

This is perfect. Thanks!

@dbachelder
Copy link

This version will account for multiple child projects of mixed type java/android/android-library

https://gist.github.com/dbachelder/9534270

Thanks a ton for the kickstart on this.

@omarmiatello
Copy link

I have some truble with this, see googlemaps/android-maps-utils#60 (comment)

my path was:

File manifestFile = file("${buildDir}/exploded-aar/com.google.maps.android/android-maps-utils/0.3/AndroidManifest.xml")

@MaxToyberman
Copy link

This is my Fix:

just put it in the release type

      android {
                applicationVariants.all { variant ->

                    variant.outputs.each { output ->
                        output.processManifest.doFirst {


                            File manifestFile = file("${buildDir}/intermediates/exploded-aar/com.ramotion.foldingcell/folding-cell/1.0.0/AndroidManifest.xml")

                            if (manifestFile.exists()) {
                                String content = manifestFile.getText('UTF-8')
                                content = content.replaceAll(/android:maxSdkVersion="17"/, '')
                                manifestFile.write(content, 'UTF-8')

                            }


                        }
                    }
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment