You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter项目构建App Bundle时遇Malformed \uxxxx编码错误求解决

构建Flutter App Bundle时出现“Malformed \uxxxx encoding”错误的解决方法

构建Flutter项目的App Bundle时失败,报错信息显示构建文件C:\Users\vidhy\cordless\android\app\build.gradle第53行存在问题,具体错误为“Malformed \uxxxx encoding”。以下是相关文件内容及完整错误日志:

build.gradle 文件内容

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localProperties.load(new FileInputStream(localPropertiesFile))
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    // Replace the line below with your desired error handling mechanism
    println "Flutter SDK location not found. Define the location with 'flutter.sdk' in the local.properties file."
    return
}

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 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.cordless"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    signingConfigs {
        release {
            def keystorePropertiesFile = rootProject.file('key.properties')
            def keystoreProperties = new Properties()
            keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

            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:$kotlin_version"
    implementation 'androidx.multidex:multidex:2.0.1'
    // Add your other dependencies here
}

完整错误日志

FAILURE: Build failed with an exception.

  • 位置:构建文件C:\Users\vidhy\cordless\android\app\build.gradle第53行
  • 问题:评估项目':app'时出现问题。

    Malformed \uxxxx encoding.

  • 建议:

    使用--stacktrace选项获取堆栈跟踪。
    使用--info或--debug选项获取更多日志输出。
    使用--scan获取完整分析信息。

BUILD FAILED in 1s
Running Gradle task 'bundleRelease'... 2,426ms
Gradle task bundleRelease failed with exit code 1.

解决方法

这个错误的核心原因是Gradle会把路径中的单反斜杠\识别为Unicode转义字符\uxxxx的开头,但后续没有合法的四位十六进制字符,通常出现在key.properties文件的storeFile路径配置中。

步骤1:修改key.properties文件路径格式

找到项目根目录下的key.properties文件,查看storeFile的配置:

  • 若原路径是单反斜杠格式(如C:\Users\vidhy\keystore.jks),改成双反斜杠:C:\\Users\\vidhy\\keystore.jks
  • 或直接改用正斜杠:C:/Users/vidhy/keystore.jks

示例修改后的key.properties:

storePassword=your_store_password
keyPassword=your_key_password
keyAlias=your_key_alias
storeFile=C:/Users/vidhy/keystore.jks

步骤2:验证路径正确性

确认修改后的路径确实指向你的keystore文件,避免拼写错误。

步骤3:重新构建项目

执行flutter build appbundle命令重新构建,检查错误是否消除。

额外排查点

若修改key.properties后问题仍存在,检查local.properties中的flutter.sdk路径是否也存在单反斜杠问题,同样按上述方法修改为双反斜杠或正斜杠。


内容的提问来源于stack exchange,提问作者Lokesh P D

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 08:12:06