找不到带有路径的平台 SDK:平台;android-P

错误:失败:生成失败,出现异常。

  • 问题所在:配置项目“:app”时出现问题。

找不到带有路径的平台 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'
    }

答案 1

步骤1:在Android工作室中打开“首选项”或“设置”。选择 Android SDK 选项并安装 Android API 28,如下所示。

install

步骤2:编译SdkVersion有一个问题,因为您必须将其从“android-P”更改为28。

compileSdkVersion 28

和构建项目。就是这样。


答案 2

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

android {
    compileSdkVersion 28

    defaultConfig {
        targetSdkVersion 28
    }
    ...
}

设置安卓P SDK


推荐