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

错误:失败:构建失败并出现异常。

  • 出了什么问题: 配置项目“:app”时出现问题。

未能找到具有路径的平台 SDK:platforms;android-P

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 'android-P'
        defaultConfig {
            applicationId "com.google.codelabs.mdc.java.shrine"
            minSdkVersion 15
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            vectorDrawables.useSupportLibrary = true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
     }

    dependencies {
        api 'com.android.support:design:28.0.0-alpha1'
        implementation 'com.android.support:support-v4:28.0.0-alpha1'
        implementation 'com.android.volley:volley:1.1.0'
        implementation 'com.google.code.gson:gson:2.8.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }

【问题讨论】:

  • 添加你的 gradle 文件
  • 我在下面添加了 gradle 代码和解决方案。

标签: java android android-gradle-plugin android-9.0-pie


【解决方案1】:

第 1 步:在 Android Studio 中打开偏好设置或设置。选择 Android SDK 选项并安装 Android API 28,如下所示。

第 2 步:compileSdkVersion 存在问题,因为您必须将其从 'android-P' 更改为 28。

compileSdkVersion 28

然后构建项目。就是这样。

【讨论】:

    【解决方案2】:

    要全面测试您的应用与 Android P 的兼容性并开始使用新的 API,请打开您的模块级 build.gradle 文件并更新 compileSdkVersion 和 targetSdkVersion,如下所示:

    android {
        compileSdkVersion 28
    
        defaultConfig {
            targetSdkVersion 28
        }
        ...
    }
    

    Set Up the Android P SDK

    【讨论】:

      【解决方案3】:

      找不到 Platform SDK 的路径:platforms;android-R

      将此代码放在最后的android/build.gradle ??

      subprojects {
          project.buildDir = "${rootProject.buildDir}/${project.name}"
      
          project.evaluationDependsOn(':app')
      
          afterEvaluate {project ->
              if (project.hasProperty("android") && project.property("android").compileSdkVersion.equals("android-R")) {
                  android {
                      compileSdkVersion 30
                  }
              }
          }
      }
      

      【讨论】:

        【解决方案4】:

        问题:找不到 Platform SDK 路径为:platforms;android-27

        解决方案:

        • 只需将compileSdkVersion 更改为30,将targetSdkVersion 更改为30,然后单击同步。系统将下载一些文件并完成。 (您需要互联网连接)
        android {
         compileSdkVersion 30
         defaultConfig {
               targetSdkVersion 30
         }
         ...
        }
        

        【讨论】:

        • 打扰一下,您能告诉我需要修改的文件名吗?
        【解决方案5】:

        需要更新compileSdkVersion和targetSdkVersion到30解决问题

        【讨论】:

          猜你喜欢
          • 2019-08-11
          • 2020-10-03
          • 2020-11-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多