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
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']
}
}
先谢了
3条答案
按热度按时间goqiplq21#
在 key.properties文件中,而不是storeFile= C:\Users\upload-keystore.jks
使用此storeFile= C:/Users/username/upload-keystore.jks
将文件路径中的
\
替换为/
。如果是这种情况,则这将解决错误。
vpfxa7rd2#
在
key.properties
文件中,在完成keystorepath storeFile=path to file
时,使用“/”代替子目录的“\”,即如果路径为C:/user/[username]/keystore.jks
(Windows中显示的路径),则将其更改为C:\user\[username]\keystore.jks
。n3h0vuf23#
我刚刚在Windows上遇到了同样的问题,这可能也是你的情况。由于提到了编码错误,我从头开始编写了www.example.com文件的内容key.properties,而不是从flutter网站复制和粘贴,这可能会引入一些字符串编码问题。然后我不再有这个错误。我仍然有一些keystore文件的路径问题,我也解决了这个问题,但这是另一个问题,而不是您遇到的问题。在这里,我只是尝试移动密钥存储库文件,并将密钥存储库文件名调整为Gradle预期的名称,以满足Gradle的要求。