android - 尝试运行颤振应用程序时,build.gradle 文件中出现错误
问题描述
在我第一次,我生成key.properties
了文件并添加到build.gradle
文件中。然后我尝试了flutter run
它不起作用。
我的build.gradle
档案。
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
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 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.example.calculator"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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"
}
解决方案
localProperties
未定义。尝试这个:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
推荐阅读
- c++ - gcc 4.8 无法检查 c++ 模板中的类型转换
- java - java.lang.SecurityException:UID 10243 在 Android 10 中没有粗略/精细定位权限
- vert.x - 如何测试不等待对其消息的确认的verticle?
- python - 无法使用 python-twitter 模块验证 Twitter 凭据
- c - 如何在 C 中使用 realloc
- flutter - 如何向后移动一些代码行?
- assembly - 处理器 8086 从八进制转换为十进制 - 汇编
- json - json 属性同时具有值和对象
- unicode - Html 电子邮件中的 Unicode 符号 - Outlook 是否把它们都弄乱了?
- python - Pandas 数据框或 SQLite 模糊搜索