我试图解决Gradle的一个烦人的问题,它不允许库有不同的最小/目标sdk' s。解决方案是将以下内容添加到build.gradle。
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)
}
}
}
然而,当我这样做时,我收到一个错误,即applicationVariants无法解析。我该如何解决这个问题?
答案 0 :(得分:1)
一般来说,这是一个Android Studio错误,它告诉我有没有错误。建立和忽略工作正常。