当前位置: 首页 > 知识库问答 >
问题:

颤振梯度。生成错误:无法获取类型为flatterExtension的扩展“flatter”的未知属性“compileSdkVersion”

吕峰
2023-03-14

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

我开始收到这个错误

错误:

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.

建筑gradle文件:

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更改为常数

JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ

JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ

共有1个答案

孙德宇
2023-03-14

试试命令

颤振清洁

颤振升级

为我工作。

 类似资料:
  • 当运行android时,我对本机项目做出了反应,显示了这个错误 生成文件'C:\dev\icnet\u final\android\app\Build。格拉德尔线:213 评估项目“: app”时出现问题。 无法获取类型为org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer的配置容器的未知属性“

  • 从2月7日起,我所有的测试都因同样的错误而失败;日志条目如下所示: 我不确定这是否是由Chrome更新或其他原因造成的——消息本身就很模糊。 编辑:我正在使用C#,和最新的ChromeDrive。

  • 我收到错误: 错误类型错误: 无法读取在评估 (webpack-internal:///./node_modules/@angular/common/esm5/http.js:163) 处未定义的属性 “长度”在 Array.forEach () 在 httpHeaders.lazyInit (webpack-internal:///./node_modules/@angular/common/e

  • 问题内容: 问题答案: 您需要升级Chromedriver版本,因为您使用的版本不支持您使用的Chrome版本。 最新版本可在此处下载: https://sites.google.com/a/chromium.org/chromedriver/downloads

  • 尝试使用< code>getAuth请求来存储令牌。请求不调用API并抛出错误。 TypeError:无法在HttpHeaders.push处读取undefined的属性(读取“length”)../node _ modules/@ angular/common/Fe sm5/http . js . http headers . apply update(http . js:199)at http

  • 我的代码: 错误: 未处理PromisejectionWarning:TypeError:无法读取未定义的未处理PromisejectionWarning:未处理的promise拒绝的属性“forEach”。此错误源于在没有catch块的情况下抛出异步函数的内部,或者拒绝使用未处理的promise。catch()。(拒绝id:1)(节点:7188)[DEP0018]弃用警告:未处理的promise