Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

We recommend using a newer Android Gradle plugin to use compileSdkPreview = "Sv2" warning in android studio

When I am running an app in android studio using Android Sv2 Preview SDK, I am getting a warning:

Build Output

We recommend using a newer Android Gradle plugin to use compileSdkPreview = "Sv2"

This Android Gradle plugin (7.2.0-alpha04) was tested up to compileSdk = 31

This warning can be suppressed by adding android.suppressUnsupportedCompileSdk=Sv2
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdkPreview = "Sv2"

build.gradle (:app)

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 31
    compileSdkPreview 'Sv2'
...
}
...

build.gradle (Project:...)

buildscript {
    ext {
        compose_version = '1.1.0-beta02'
        agp_version = '7.2.0-alpha04'
    }
}// Top-level build file where you can add configuration options common to all sub- 
projects/modules.
plugins {
    id 'com.android.application' version '7.2.0-alpha04' apply false
    id 'com.android.library' version '7.2.0-alpha04' apply false
    id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

where can I get the correct AGP(Android Gradle plugin) version?

What is apply false in

plugins {
    id 'com.android.application' version '7.2.0-alpha04' apply false
    id 'com.android.library' version '7.2.0-alpha04' apply false
    id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
like image 979
Vidyesh Churi Avatar asked Dec 07 '25 08:12

Vidyesh Churi


2 Answers

This is not a error, This is only a warning that you will only encounter in stable version of Android Studio,

Because Android Sdk 32 does not have a stable version release, it is currently in beta version. Stable version of Android Studio recommends to use stable version of Android Gradle Plugin and therefore shows a warning when you use beta version of android SDK as compileSDK,

So the best solution is to ignore the warning or downgrade the version of compileSDK to current stable version which is 31 or suppress warning by adding "android.suppressUnsupportedCompileSdk=32" to gradle.properties. However if you really want to checkout features of new Android, use Android Studio Canary which is explicitly built for beta version of Android SDK, beta version Android Gradle Plugin and latest Gradle version. if above warning also shows up in android canary with latest version of Android Gradle Plugin, it means Android Gradle Plugin for new SDK has not been released, So there is no solution until or unless Android Gradle Plugin for new SDK is released.

like image 77
Suresh Chaudhari Avatar answered Dec 08 '25 22:12

Suresh Chaudhari


Change agp_version version from 7.2.0-alpha04 to 7.2.2 .

Inside Project level build.gradle :

buildscript {
    ext {
        compose_version = '1.1.0-beta02'
        agp_version = '7.2.2'
    }
}

This works for me.

like image 44
Antonio Guerra Avatar answered Dec 08 '25 22:12

Antonio Guerra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!