[英]Flutter Could not find method Properties() for arguments [] on project ':app' of type org.gradle.api.Project
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 = '44'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '4.4'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 29
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.credfinance.credfinance"
minSdkVersion 19
targetSdkVersion 29
versionCode 44
versionName '4.4'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
OUT PUT:输出:
mac@Macs-MacBook-Air credapp % flutter run Launching lib/main.dart on SM N950U in debug mode... mac@Macs-MacBook-Air credapp % flutter run 在调试模式下在 SM N950U 上启动 lib/main.dart...
FAILURE: Build failed with an exception. FAILURE:构建失败并出现异常。
Where:在哪里:
Build file '/Users/mac/Documents/Flutter_Project/credapp/android/app/build.gradle' line: 28构建文件'/Users/mac/Documents/Flutter_Project/credapp/android/app/build.gradle' 行:28
What went wrong:什么地方出了错:
A problem occurred evaluating project ':app'.评估项目 ':app' 时出现问题。
Could not find method Properties() for arguments [] on project ':app' of type org.gradle.api.Project.
在 org.gradle.api.Project 类型的项目 ':app' 上找不到 arguments [] 的方法 Properties()。
Try:尝试:
Run with --stacktrace option to get the stack trace.使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output.
使用 --info 或 --debug 选项运行以获得更多日志 output。 Run with --scan to get full insights.
运行 --scan 以获得完整的见解。
Get more help at https://help.gradle.org在https://help.gradle.org获得更多帮助
BUILD FAILED in 0s 0 秒内构建失败
Running Gradle task 'assembleDebug'...运行 Gradle 任务“assembleDebug”...
Running Gradle task 'assembleDebug'... Done 2.8s Exception: Gradle task assembleDebug failed with exit code 1 mac@Macs-MacBook-Air credapp %运行 Gradle 任务“assembleDebug”...完成 2.8 秒异常:Gradle 任务 assembleDebug 失败,退出代码为 1 mac@Macs-MacBook-Air credapp %
add 'new' keyword wherever its throwing the problem.在引发问题的任何地方添加“新”关键字。
For me为了我
if (keystorePropertiesFile.exists()) {
keystoreProperties.load( FileInputStream(keystorePropertiesFile))}
was throwing error抛出错误
if (keystorePropertiesFile.exists()) {
keystoreProperties.load( new FileInputStream(keystorePropertiesFile))}
saved the day挽救了一天
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.