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

问题描述

构建文件中有错误。我尝试了所有方法,但没有收到此错误FAILURE: Build failed with an exception。

格式错误的 \uxxxx 编码。

BUILD FAILED in 6s Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... 完成 7.4s Gradle task assembleRelease 失败,退出代码为 1

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
    }

'''

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))
   }
    
   

     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']
       }
   }

  
 '''

提前致谢

PS这是我第一次在堆栈溢出上发帖,所以如果帖子格式有任何错误,请忽略,对此我深表歉意。

标签: androidflutterdartgradlebuild

解决方案


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

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

替换\/文件路径中。

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


推荐阅读