Search code examples
androidandroid-12

Failed to find Platform SDK with path: platforms;android-31


I was about to update the support SDK to the latest version of Android which is SDK 31 "S" but It has some issue with Gradle sync.

The error

Failed to notify build listener.
Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.   
Could not create task ':app:minifyDebugWithR8'.
Cannot query the value of this provider because it has no value available.
Failed to stop service 'com.android.build.gradle.internal.errors.SyncIssueReporterImpl$GlobalSyncIssueService_5d47b2c0-a1a4-43ab-bbdb-bb6abdacb3ba'.
Failed to find Platform SDK with path: platforms;android-31

This is the setup

compileSdk 31

    defaultConfig {
        applicationId "com.app.app
        minSdk 21
        targetSdk 31
        versionCode 7
        versionName "1.0.9"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

Already using the latest AGP com.android.tools.build:gradle:7.1.0-alpha01

Already install the Android "S" Preview tools as well. enter image description here

Lastly already has the latest AS version preview

Android Studio Bumblebee | 2021.1.1 Canary 1 Build #AI-203.7717.56.2111.7361063, built on May 14, 2021

Following the documentation not working as well.

No signature of method: build_cdzmabn9imuzupf8f433s2vnq.android() is applicable for argument types: (build_cdzmabn9imuzupf8f433s2vnq$_run_closure1) values: [build_cdzmabn9imuzupf8f433s2vnq$_run_closure1@6f573027]

The Gradle sync is success with

compileSdkPreview "android-S"
targetSdkPreview "S"

But the app cannot install at all on any device neither release or debug.

What else should we do?


Solution

  • You should read the migration document provided by Google carefully: https://developer.android.com/about/versions/12/migration

    Google usually don't want you to update your targetSdkVersion in your production environment before the SDK hits platform stability (see the timeline here), but rather test to test it locally. Once the latest APIs are finalized, they expect most apps to update the targetSdkVersion to say they certify that this app is compatible with the given SDK level. Lately Google started to enforce a ~year long grace period before they start enforcing that all new apps should target the latest SDK.