firebase 无法在flutter中构建apk,因为我在android/app/build.gradle中出错

tv6aics1  于 12个月前  发布在  Flutter
关注(0)|答案(1)|浏览(130)

当我尝试运行flutter build apk时,我无法生成apk,并且在build gradle中显示错误。
我得到的错误:-失败:生成失败,出现异常。

  • 哪里出错了:执行任务“:app:packageRelease”失败。

执行com.android.build.gradle.tasks时出错。PackageAndroidError $IncrementalSplitterRunnable SigningConfig“release”缺少必需的属性“storeFile”。

  • 试试看:

使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。运行--扫描以获得完整的见解。

BUILD FAQURY in 1 m 5s Running Gradle task 'VerleRelease'. 66.5s Gradle任务ControlleRelease失败,退出代码为% 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 = '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"
apply plugin: 'com.google.gms.google-services'

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
namespace "com.example.tis_root01"
compileSdkVersion flutter.compileSdkVersion
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 {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.tis_root01"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion Math.max(flutter.minSdkVersion,24)
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

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"
}
ckocjqey

ckocjqey1#

检查项目的Android文件夹中是否有key.properties文件。
我认为这个错误与它有关,因为它是在它指定的

SigningConfig "release" is missing required property "storeFile".

并确保使用与build.gradle文件中的签名配置中所写的相同的variable名称。
使用此

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}

并确保你有
keyAlias =您的密钥别名
keyPassword =您的密钥密码
storeFile =密钥存储文件路径
storePassword =您的密钥存储密码
检查你的key.properties文件中是否有所有这些

相关问题