首页 > 解决方案 > 无法找到具有路径的平台 SDK:平台;android-R

问题描述

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

出了什么问题:配置项目“:app”时出现问题。无法找到具有路径的平台 SDK:平台;android-P

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
        maven {
            url 'http://storage.googleapis.com/r8-releases/raw'
        }
    }

    dependencies {
        classpath 'com.android.tools:r8:1.5.25'
        classpath 'com.google.gms:google-services:4.3.2'
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

标签: androidflutter

解决方案


please put this code at the end of android/build.gradle Hopefully, it solves your issue.

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

推荐阅读