找不到路径为 Platform SDK 的平台;android-P
Failed to find Platform SDK with path: platforms;android-P
错误:失败:构建失败,出现异常。
- 出了什么问题:
配置项目“:app”时出现问题。
Failed to find Platform SDK with path: 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'
}
第 1 步:在 Android studio 中打开首选项或设置。 Select Android SDK 选项和安装 Android API 28 如下选择。
第 2 步:compileSdkVersion 有问题,您必须将其从 'android-P' 更改为 28。
compileSdkVersion 28
并构建项目。就是这样。
要全面测试您的应用与 Android P 的兼容性并开始使用新的 API,请打开您的模块级 build.gradle 文件并更新 compileSdkVersion 和 targetSdkVersion,如下所示:
android {
compileSdkVersion 28
defaultConfig {
targetSdkVersion 28
}
...
}
找不到路径为 Platform SDK 的平台;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
}
}
}
}
问题:找不到路径为 Platform SDK 的平台;android-27
解决方案:
- 只需将
compileSdkVersion
更改为 30,将 targetSdkVersion
更改为 30,然后单击同步。系统将下载一些文件并完成。 (为此你需要互联网连接)
android {
compileSdkVersion 30
defaultConfig {
targetSdkVersion 30
}
...
}
需要更新compileSdkVersion和targetSdkVersion为30解决问题
错误:失败:构建失败,出现异常。
- 出了什么问题: 配置项目“:app”时出现问题。
Failed to find Platform SDK with path: 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'
}
第 1 步:在 Android studio 中打开首选项或设置。 Select Android SDK 选项和安装 Android API 28 如下选择。
第 2 步:compileSdkVersion 有问题,您必须将其从 'android-P' 更改为 28。
compileSdkVersion 28
并构建项目。就是这样。
要全面测试您的应用与 Android P 的兼容性并开始使用新的 API,请打开您的模块级 build.gradle 文件并更新 compileSdkVersion 和 targetSdkVersion,如下所示:
android {
compileSdkVersion 28
defaultConfig {
targetSdkVersion 28
}
...
}
找不到路径为 Platform SDK 的平台;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
}
}
}
}
问题:找不到路径为 Platform SDK 的平台;android-27
解决方案:
- 只需将
compileSdkVersion
更改为 30,将targetSdkVersion
更改为 30,然后单击同步。系统将下载一些文件并完成。 (为此你需要互联网连接)
android {
compileSdkVersion 30
defaultConfig {
targetSdkVersion 30
}
...
}
需要更新compileSdkVersion和targetSdkVersion为30解决问题