gpt4 book ai didi

android -\android\build.gradle 行 : 14 : unexpected token: { 中的意外 token

转载 作者:行者123 更新时间:2023-12-04 23:45:12 25 4
gpt4 key购买 nike

尝试使用构建项目时

flutter build apk --split-per-abiI however get the following error:

FAILURE: Build failed with an exception.
  • 在哪里:
    构建文件 'C:\proeject\android\app\build.gradle' 行:34
  • 什么地方出了错:
    无法编译构建文件“C:\proeject\android\app\build.gradle”。

  • startup failed:build file 'C:\project\android\app\build.gradle': 34: Unexpected input: '{' @ line 34, column 9.android {^


    1 个错误
  • 尝试:
    使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
  • https://help.gradle.org 获得更多帮助

  • 我的代码:
    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"

    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }

    android {
    compileSdkVersion 30

    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.company.project"
    minSdkVersion 23
    targetSdkVersion 30
    versionCode 1
    versionName 1.0.0
    }

    signingConfigs {
    release {
    storeFile file('../keystore/key.jks')
    storePassword file('../keystore/keystore.password').text.trim()
    keyPassword file('../keystore/keystore.password').text.trim()
    keyAlias 'key'
    }
    }

    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.release

    minifyEnabled true
    useProguard true

    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }
    }

    flutter {
    source '../..'
    }

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

    最佳答案

    不确定它会解决你的问题,但我也面临同样的问题。但我不知道为什么配置不安全的方式解决了我的问题。我只是替换下面的代码:

       release {
    storeFile file('your_key_name.keystore')
    storePassword System.console().readLine("\nKeystore password:")
    keyAlias System.console().readLine("\nAlias: ")
    keyPassword System.console().readLine("\Alias password: ")
    }
    release {
    storeFile file('your_key_name.keystore')
    storePassword 'your_key_store_password'
    keyAlias 'your_key_alias'
    keyPassword 'your_key_file_alias_password'
    }
    它对我有用。

    关于android -\android\build.gradle 行 : 14 : unexpected token: { 中的意外 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69104075/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com