Reputation: 413
This is the error that I'm getting when I'm trying to run "flutter build appbundle" in terminal. I already search for some solution but none of it has the same error as I get
FAILURE: Build failed with an exception.
Where: Build file 'C:\Users\User_Name\Desktop\deploy\bahetra\android\app\build.gradle' line: 31
What went wrong: A problem occurred evaluating project ':app'.
Malformed \uxxxx encoding.
This is the code from my "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)) // line 31
}
android {
compileSdkVersion 30
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.example.bahetra"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
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-jdk7:$kotlin_version"
}
Upvotes: 41
Views: 15237
Reputation: 71
First of run terminal as Run As Administrator and than
keytool -genkey -keyalg RSA -alias selfsigned -keystore upload-keystore.jks -storepass %password% -validity 360 -keysize 2048
%password% is your password
Upvotes: 0
Reputation: 41
The problem is in the key.properties file. The store location contains backslashes, which need to be replaced with forward slashes. This will fix the issue. For example,
Update this in key.properties file:
storeFile= C:\Users\<user name>\upload-keystore.jks
to this:
storeFile=C://Users//<user name>//upload-keystore.jks
Upvotes: 4
Reputation: 81
just replace the backslash to forward-slash in key.properties in storeFile
before
storeFile=<location>\upload-keystore.jks
after
storeFile=<location>/upload-keystore.jks
Upvotes: 5
Reputation: 1
in key.properties file: must storeFile=C:\Users\\upload-keystore.jks
Upvotes: 0
Reputation: 1496
The issue is in key.properties file. Replace all the backslash in the store location with the forward slash and it should work. Eg:
Update this in key.properties file:
storeFile= C:\Users\<user name>\upload-keystore.jks
to this:
storeFile=C:/Users/<user name>/upload-keystore.jks
Upvotes: 148