flutter 在Play Store中发布应用程序之前的步骤之后,我在build.gradle文件中遇到错误

ohfgkhjo  于 2023-02-25  发布在  Flutter
关注(0)|答案(1)|浏览(131)

我将在Play Store上发布我的Flutter应用程序。为此,我在此处执行了Gradle中的配置登录步骤。
完成此操作后,当我键入flutter build appbundle命令时,我开始收到一个错误,错误如下:

PS C:\Dosyalar\Yazilim\Flutter\Deprem SafeArea\safearea> flutter build appbundle

 Building with sound null safety 

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Dosyalar\Yazilim\Flutter\Deprem SafeArea\safearea\android\app\build.gradle' line: 51

* 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

BU�LD FAILED in 1s
Running Gradle task 'bundleRelease'...                           2.487ms
Gradle task bundleRelease failed with exit code 1

安卓系统/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"

android {
    compileSdkVersion 33
    ndkVersion flutter.ndkVersion
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    defaultConfig {
        applicationId "visible"
        minSdkVersion 23
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }

    signingConfigs {
        debug {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

如何解决错误?

thtygnil

thtygnil1#

请尝试将第51行从if (keystorePropertiesFile.exists()) {更改为if (keystorePropertiesFile.exists() && keystorePropertiesFile != null) {

相关问题