【问题标题】:Error when building signed apk for flutter (malformed)为颤振构建签名 apk 时出错(格式错误)
【发布时间】:2021-06-22 03:35:06
【问题描述】:

我在终端中收到此错误,我希望在 Play 商店中以内部测试模式发布应用程序,当我在 deub 模式下构建它时它很好,但 Play 商店不接受在调试模式下发布,所以我更改了配置并签署了应用程序以在发布模式下构建

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

这是我的 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 = '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"
}

【问题讨论】:

标签: java android flutter dart gradle


【解决方案1】:

我认为您的“keystorePropertiesFile”有问题。您需要检查其中的Keystore文件的文件路径。

例如,用正斜杠替换所有反斜杠,它应该可以工作,因为正如你所说,问题只有在你发布时才会出现,所以它必须在“keystorePropertiesFile”中有问题。

【讨论】:

  • 'FAILURE:构建失败并出现异常。 * 出了什么问题:任务 ':app:validateSigningRelease' 执行失败。 > 未找到用于签名配置 'release' 的密钥库文件 'C:\Users\Ahmed\mobile-app\android\app\"C:\Users\Ahmed\upload-keystore.jks"'。`
  • 我得到这个错误现在添加双反斜杠也尝试使用双正斜杠和简单正斜杠
  • 我认为现在可以工作了,PS C:\Users\Ahmed\mobile-app> flutter build apk Building without sound null safety 如需更多信息,请参阅dart.dev/null-safety/unsound-null-safety Running Gradle task 'assembleRelease'...运行 Gradle 任务 'assembleRelease'... 完成 12.2 秒 √ 构建 build\app\outputs\flutter-apk\app-release.apk (37.9MB)。
  • 一个问题是它取代了以前的版本吗?调试的?
  • 如果你正在发布,那么它不会影响调试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-12
  • 1970-01-01
  • 2019-07-14
  • 2020-08-25
  • 2020-12-18
相关资源
最近更新 更多