【问题标题】:Flutter build Appbundle Error:* What went wrong: A problem occurred evaluating project ':app'Flutter build Appbundle 错误:* 出了什么问题:评估项目“:app”时出现问题
【发布时间】:2021-07-31 22:42:23
【问题描述】:

这是我在终端中尝试运行“flutter build appbundle”时遇到的错误。 我已经在寻找一些解决方案,但没有一个与我得到的错误相同

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

  • 在哪里: 构建文件 'C:\Users\User_Name\Desktop\deploy\bahetra\android\app\build.gradle' 行:31

  • 出了什么问题: 评估项目 ':app' 时出现问题。

格式错误的 \uxxxx 编码。

这是我的“android\app\build.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"

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

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.example.bahetra"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
}

flutter {
    source '../..'
}

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

【问题讨论】:

    标签: android flutter dart


    【解决方案1】:

    问题出在 key.properties 文件中。用正斜杠替换存储位置中的所有反斜杠,它应该可以工作。例如:

    在 key.properties 文件中更新这个:

    storeFile= C:\Users\<user name>\upload-keystore.jks
    

    到这里:

    storeFile=C:/Users/&lt;user name&gt;/upload-keystore.jks

    【讨论】:

    • 非常感谢这个答案救了我
    • 挣扎了好几个小时才找到这个。严重颤振需要更新他们的文档
    • 即使在这之后我也有全新的错误Could not resolve all artifacts for configuration ':app:debugAndroidTestCompileClasspath'.
    猜你喜欢
    • 2021-09-07
    • 1970-01-01
    • 2020-08-11
    • 2021-06-26
    • 2020-03-24
    • 1970-01-01
    • 2021-10-07
    • 2021-04-09
    • 2020-02-13
    相关资源
    最近更新 更多