Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 302
tyler Avatar asked Nov 11 '22 08:11

tyler


1 Answers

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

like image 79
tyler Avatar answered Nov 15 '22 01:11

tyler