如何解决 flutter 中的 build.gradle 错误。如何解决此错误“评估项目 ':app' 时出现问题。> \uxxxx 编码格式错误。”

Abh*_*301 3 android build gradle dart flutter

Flutter (android):使用 Gradle 构建错误

构建文件中有错误。我尝试了一切,但没有任何效果。我收到以下错误消息。

错误信息

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Flutter App\covid19\android\app\build.gradle' line: 31

* What went wrong:
A problem occurred evaluating project ':app'.
> Malformed \uxxxx encoding.

* Try:
Run with --stacktrace option to get the stack trace. 
Run with --info or --debug option to get more log output. 
Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                       7.4s
Gradle task assembleRelease failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

android文件夹中的build.gradle文件

    buildscript {
            ext.kotlin_version = '1.3.50'
            repositories {
                google()
                jcenter()
            }
    
    dependencies {
                classpath 'com.android.tools:r8:2.1.75'
                classpath 'com.google.gms:google-services:4.3.2'
                classpath 'com.android.tools.build:gradle:4.1.1'
                classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            }
        }
        
    allprojects {
            repositories {
                 google()
                 jcenter()
      }
    }
            
     rootProject.buildDir = '../build'
        subprojects {
            project.buildDir = "${rootProject.buildDir}/${project.name}"
        }
        subprojects {
            project.evaluationDependsOn(':app')
        }
        
        task clean(type: Delete) {
            delete rootProject.buildDir
        }
Run Code Online (Sandbox Code Playgroud)

Android应用程序文件夹中的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))
       }
        
       
    
         android {
                compileSdkVersion 28
            
                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.abhishekbhamare.covid19"
                minSdkVersion 16
                targetSdkVersion 28
                versionCode flutterVersionCode.toInteger()
                versionName flutterVersionName
            }
            
     
    
     signingConfigs {
           release {
               keyAlias keystoreProperties['keyAlias']
               keyPassword keystoreProperties['keyPassword']
               storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
               storePassword keystoreProperties['storePassword']
           }
       }
Run Code Online (Sandbox Code Playgroud)

提前致谢

aka*_*rya 7

在 key.properties 文件中,而不是 storeFile= C:\Users<username>\upload-keystore.jks

使用这个storeFile= C:/Users/username/upload-keystore.jks

替换\/文件路径中的内容。

如果是这种情况,这将解决该错误。