构建Flutter应用程序的发行版会返回此错误

问题描述 投票:0回答:1

我正在准备将自己的flutter应用程序发布到Playstore中,这会给我这个错误:

错误:

* Where:
Build file 'C:\Users\svesp\Desktop\Vlad Esplana\syncshop_webview\android\app\build.gradle' line: 60

* What went wrong:
A problem occurred evaluating project ':app'.
> path may not be null or empty string. path='null'

我的key.properties

storePassword=hidden
keyPassword=hidden
keyAlias=random
storeFile=C:/Users/svesp/key.jks

我的应用级别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'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.hivemanila.syncshop_webview"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

   signingConfigs {
       release {
           keyAlias keystoreProperties['hidden']
           keyPassword keystoreProperties['hidden']
           storeFile file(keystoreProperties['C:/Users/svesp/key.jks'])
           storePassword keystoreProperties['hidden']
       }
   }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
android flutter flutter-layout flutter-dependencies
1个回答
1
投票

只需将您的signingConfigs更改为以下内容,

signingConfigs {
       release {
            keyAlias keystoreProperies["keyAlias"]  
            keyPassword keystoreProperies["keyPassword"]  
            storeFile file(keystoreProperies["storeFile"])  
            storePassword keystoreProperies["storePassword"]  
       }
   }

只需从中回复您的代码

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

收件人

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperiesFile = rootProject.file("key.properties")  
def keystoreProperies = new Properties()  
keystoreProperies.load(new FileInputStream(keystoreProperiesFile)) 
© www.soinside.com 2019 - 2024. All rights reserved.