【问题标题】:Failed to find Platform SDK with path: platforms;android-31无法找到具有路径的平台 SDK:platforms;android-31
【发布时间】:2021-05-22 12:37:40
【问题描述】:

我正准备将支持 SDK 更新到最新版本的 Android,即 SDK 31 "S",但 Gradle 同步存在一些问题。

错误

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

这是设置

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"
    }

已经在使用最新的 AGP com.android.tools.build:gradle:7.1.0-alpha01

也已安装 Android“S”预览工具。

终于有了最新的AS版本预览

Android Studio Bumblebee | 2021.1.1 金丝雀 1 构建 #AI-203.7717.56.2111.7361063,构建于 2021 年 5 月 14 日

documentation 之后效果不佳。

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

Gradle 同步成功

compileSdkPreview "android-S"
targetSdkPreview "S"

但该应用程序根本无法安装在任何设备上,无论是发布还是调试。

我们还应该做什么?

【问题讨论】:

  • 你还在面对这个问题吗?
  • @HamidShatu 不确定是否再试一次,因为它看起来还没有准备好投入生产。

标签: android android-12


【解决方案1】:

请仔细阅读谷歌提供的迁移文档:https://developer.android.com/about/versions/12/migration

Google 通常不希望您在 SDK 达到平台稳定性之前在生产环境中更新您的 targetSdkVersion(请参阅时间线 here),而是在本地进行测试以对其进行测试。一旦最新的 API 最终确定,他们希望大多数应用程序更新 targetSdkVersion 以表明他们证明此应用程序与给定的 SDK 级别兼容。最近,Google 开始强制执行长达一年的宽限期,然后才开始强制所有新应用都应针对最新的 SDK。

【讨论】:

【解决方案2】:

将 compileSdk 和 targetSdk 版本从 31 降级到 30 解决了我的问题。 不建议这样做。但在紧急情况下使用它。

【讨论】:

    猜你喜欢
    • 2018-12-13
    • 2019-08-11
    • 2020-10-03
    • 2020-11-12
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 2011-04-02
    相关资源
    最近更新 更多