Java 找不到路径为 Platform SDK 的平台 SDK;android-P

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51183581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 23:59:34  来源:igfitidea点击:

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

javaandroidandroid-gradle-pluginandroid-9.0-pie

提问by Jay Halani

Error:FAILURE: Build failed with an exception.

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

  • What went wrong: A problem occurred configuring project ':app'.
  • 出了什么问题:配置项目“:app”时出现问题。

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

找不到路径为 Platform SDK 的平台 SDK;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'
    }

采纳答案by Jay Halani

Step 1: Open Preferences or Settings in Android studio. Select Android SDK options and Install Android API 28 as selected below.

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

install

安装

Step 2: There's a problem with compileSdkVersion as you have to change it from 'android-P' to 28.

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

compileSdkVersion 28

And Build project. That's it.

并构建项目。就是这样。

回答by Brijesh Joshi

To fully test your app's compatibility with Android P and begin using new APIs, open your module-level build.gradle file and update the compileSdkVersion and targetSdkVersion as shown here:

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

android {
    compileSdkVersion 28

    defaultConfig {
        targetSdkVersion 28
    }
    ...
}

Set Up the Android P SDK

设置 Android P SDK