android - flutter build apk --debug 在没有发布密钥库的情况下无法构建调试
问题描述
我的 Flutter 应用无法构建调试版本。我用签名密钥很好地构建了发布,但现在尝试构建调试它正在寻找 storeFile(它不存在,因为我已经将代码带到了另一台没有密钥的机器上)。我正在运行:
flutter build apk --debug
但它失败了
运行 Gradle 时出错:ProcessException: Process ...\android\gradlew.bat" 异常退出:
FAILURE:构建失败并出现异常。
其中:构建文件 ...\android\app\build.gradle'行:54
出了什么问题:评估项目“:app”时出现问题。path 不能为 null 或空字符串。路径='空'
第 54 行在用于签名配置的版本中
storeFile file(keystoreProperties['storeFile'])
不应该--debug忽略这个吗?当这是一个调试版本时,为什么它试图访问该文件?
这是带有注释的版本的 build.gradle 文件,因此我可以在没有密钥库的情况下构建调试:
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.6'
}
apply plugin: 'com.android.application'
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 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.mycompany.myproduct"
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
// signingConfigs {
// release {
// keyAlias keystoreProperties['keyAlias']
// keyPassword keystoreProperties['keyPassword']
// storeFile file(keystoreProperties['storeFile'])
// storePassword keystoreProperties['storePassword']
// }
// }
// buildTypes {
// release {
// signingConfig signingConfigs.release
// minifyEnabled true
// useProguard true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }
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.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
解决方案
一定是某个地方的顶部空间错误,但我完全删除并重新安装了除 Windows 之外的所有内容,并且重新开始营业。我讨厌不知道这是横向的...
推荐阅读
- python - 如何在 Pandas 中过滤掉具有特定值的行后创建数据帧的反转
- sql-server - MSSQL BCP 链接服务器
- jquery - 在使用区填充块之前添加一个空值,等等使用 Ajax
- bash - 如何使用 bash 在 docker 容器中获取僵尸进程
- java - android检查URL是否包含来自数组的站点名称总是返回false
- javascript - 如何有效地形成具有 2 个数组的对象
- c++ - C++ 11 中与 std::atomic 的同步
- css - Bootstrap 排版显示字体类在我的本地 Web 开发环境中呈现不同的文本大小
- sql - 查询在瑞士获得计数至少为 1 的名称
- python - 在 Webhook 中将字节转换为字符串的问题 - LoggerDebug - Python3