android - 如何解决颤振中的 build.gradle 错误。如何解决此错误“评估项目 ':app' 时出现问题。> 格式错误的 \uxxxx 编码。”
问题描述
构建文件中有错误。我尝试了所有方法,但没有收到此错误FAILURE: Build failed with an exception。
其中:构建文件 'D:\Flutter App\covid19\android\app\build.gradle' 行:31
出了什么问题:评估项目“:app”时出现问题。
格式错误的 \uxxxx 编码。
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
在https://help.gradle.org获得更多帮助
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这是我第一次在堆栈溢出上发帖,所以如果帖子格式有任何错误,请忽略,对此我深表歉意。
解决方案
在您的 key.properties 文件中,而不是 storeFile= C:\Users<username>\upload-keystore.jks
使用这个 storeFile=C:/Users/username/upload-keystore.jks
替换\
为/
文件路径中。
如果是这种情况,这将解决错误。
推荐阅读
- node.js - Inversify - Nodejs- 容器绑定导致超出最大调用大小
- jsp - 如何检查对 index.ftl 的 HTTP 请求?
- python - 是否可以在 Pandas.ReadSQL 中使用“chunksize=”选项来限制/限制内存/RAM 的使用?
- reactjs - rc-滑块图标或 html 标签
- python - 我在 python 3.6 中安装 webdrive 模块时遇到问题
- algorithm - 对于允许重叠的覆盖问题,是否有众所周知或有效的算法?
- typo3 - 有没有办法在typo3中可见的前端添加记录更改成为历史?
- c++ - 如何对对象进行异步销毁并立即分配一个新对象
- c# - 将数据从主页上的 web api 传递到 xamarin 表单中的详细信息页面
- string - 在打字稿中连接字符串时如何匹配字符串文字类型