简体   繁体   中英

Error when building signed apk for flutter (malformed)

I am getting this error in the terminal, I am looking to release the app in internal testing mode on play store, when i was building it in degub mode it was fine, but play store doesn't accept releases in debug mode, so I change configuration and signed the app to build in release mode

PS C:\Users\Ahmed\mobile-app> flutter build apk

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Build file 'C:\Users\Ahmed\mobile-app\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 2s                                                      
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                       3.5s
Gradle task assembleRelease failed with exit code 1

This is my build.gradle file

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 = '2'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0.2'
}

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 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.mylo.donation_yoga"
        minSdkVersion 29
        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"
}

I think something is wrong with your "keystorePropertiesFile". You need to check the file path of the Keystore file in it.

For Example, Replace all the backslash with the forward-slash and it should work because as you told the problem comes only when you do the release so it has to be something wrong in the "keystorePropertiesFile".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM