简体   繁体   中英

Android Studio Gradle Cannot resolve symbol 'applicationVariants'

I'm trying to get around an annoying issue with Gradle that does not allow libraries to have different min/target sdk's. The solution was to add the following to 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)
        }
    }
}

However when i do that, I get an error that applicationVariants cannot be resolved. How do I fix this?

Aparrently, this is an Android Studio bug and is telling me there are errors where there's none. Building and ignoring works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM