Ich versuche ein nerviges Problem mit Gradle zu umgehen, das Bibliotheken nicht erlaubt unterschiedliche Min/Ziel SDKs zu haben. Die Lösung bestand darin, Folgendes zu build.gradle hinzuzufügen.Android Studio Gradle Das Symbol 'applicationVariants' kann nicht aufgelöst werden.
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)
}
}
}
Allerdings, wenn ich das tue, bekomme ich einen Fehler, dass ApplicationVariants nicht gelöst werden kann. Wie behebe ich das?
Die IDE gibt Ihnen viele falsche Fehler, wenn Sie Android Studio verwenden. Ignoriere sie einfach, wenn sie sauber erstellt wird. Wenn ich meine Build-Datei anschaue, bekomme ich auch diesen Fehler für applicationVariants, aber es baut sich immer noch auf. – ashishduh
Huh, du hast Recht. Mach es zur Antwort! – styler1972
Das funktioniert gut für mich. Kannst du Jungs eine Antwort hinzufügen? @ styler1972 –