我的Flutter应用无法构建调试版本。我使用签名密钥构建了发行版,但是现在尝试构建调试它正在寻找storeFile(不存在,因为我将代码带到了没有密钥的另一台机器上)。我正在跑步:
flutter build apk --debug
但是失败了
运行Gradle时出错:ProcessException:进程 ... \ android \ gradlew.bat“异常退出:
失败:构建失败,并出现异常。
位置:构建文件... \ android \ app \ build.gradle'行:54
出了什么问题:评估项目':app'时发生问题。路径 不能为null或空字符串。 path ='null'
第54行是用于签名配置的版本
storeFile file(keystoreProperties['storeFile'])
-调试不应该忽略它吗?为什么这是调试版本,为什么要尝试获取该文件?
这里是带发行版的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'
答案 0 :(得分:0)
在某处一定是顶空错误,但我完全删除并重新安装了Windows以外的所有内容,然后又恢复了正常运行。我不知道这是怎么回事...