Reputation: 304
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...
FAILURE: Build failed with an exception.
Where:
Build file '/Users/mac/Documents/Flutter_Project/credapp/android/app/build.gradle' line: 28
What went wrong:
A problem occurred evaluating project ':app'.
Could not find method Properties() for arguments [] on project ':app' of type org.gradle.api.Project.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 0s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 2.8s
Exception: Gradle task assembleDebug failed with exit code 1
mac@Macs-MacBook-Air credapp %
Upvotes: 0
Views: 2971
Reputation: 351
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
Upvotes: 4