首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >颤振gradle.build错误:无法获得FlutterExtension类型扩展“颤振”的未知属性“compileSdkVersion”

颤振gradle.build错误:无法获得FlutterExtension类型扩展“颤振”的未知属性“compileSdkVersion”
EN

Stack Overflow用户
提问于 2021-12-22 13:44:02
回答 1查看 7.3K关注 0票数 7

我手动将一个颤振项目添加到AndroidStudioProjects目录中。

我开始犯这个错误

错误:

代码语言:javascript
运行
复制
FAILURE: Build failed with an exception.

 * Where:
Build file 'C:\Users\username\AndroidStudioProjects\projectName\android\app\build.gradle' line: 29

 * What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'compileSdkVersion' for extension 'flutter' of type FlutterExtension.

build.gradle文件:

代码语言:javascript
运行
复制
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion flutter.compileSdkVersion     // FAILURE: Build failed with an exception.

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.newweather"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

我试过这些,它们不管用:

https://stackoverflow.com/a/60565001/17740672

将compileSdkVersion更改为常量

EN

回答 1

Stack Overflow用户

发布于 2022-02-07 08:00:54

尝试这些命令

颤振清洗

颤振升级

为我工作过。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70450035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档