From 2f70917908d064d49413fdac8703bd4901efd744 Mon Sep 17 00:00:00 2001 From: tamslo Date: Mon, 18 Nov 2024 17:39:14 +0100 Subject: [PATCH] build(app): adapt Android build setup --- app/android/app/build.gradle | 42 ++++++++++--------- app/android/build.gradle | 17 +------- .../gradle/wrapper/gradle-wrapper.properties | 4 +- app/android/settings.gradle | 30 +++++++++---- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/app/android/app/build.gradle b/app/android/app/build.gradle index b605f436a..88d3d85e4 100644 --- a/app/android/app/build.gradle +++ b/app/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,6 +12,12 @@ if (localPropertiesFile.exists()) { } } +def keystoreProperties = new Properties() +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 Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") @@ -21,35 +33,31 @@ 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 { namespace 'de.hpi.pharme' - - compileSdk flutter.compileSdkVersion + compileSdk = flutter.compileSdkVersion + ndkVersion = "27.0.12077973" compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '17' - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + jvmTarget = JavaVersion.VERSION_17 } defaultConfig { applicationId 'de.hpi.pharme' minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName multiDexEnabled true - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + } + + dependencies { + implementation 'com.android.support:multidex:1.0.3' } buildTypes { @@ -64,7 +72,3 @@ android { flutter { source '../..' } - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/app/android/build.gradle b/app/android/build.gradle index 329f8738d..e0e4fa6fc 100644 --- a/app/android/build.gradle +++ b/app/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.8.0' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() @@ -63,13 +50,13 @@ subprojects { } } } - project.buildDir = "${rootProject.buildDir}/${project.name}" - project.evaluationDependsOn(":app") } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { project.evaluationDependsOn(':app') } diff --git a/app/android/gradle/wrapper/gradle-wrapper.properties b/app/android/gradle/wrapper/gradle-wrapper.properties index 5c6f89dba..348c409ea 100644 --- a/app/android/gradle/wrapper/gradle-wrapper.properties +++ b/app/android/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip -networkTimeout=10000 -validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip diff --git a/app/android/settings.gradle b/app/android/settings.gradle index 44e62bcf0..f83f10ea5 100644 --- a/app/android/settings.gradle +++ b/app/android/settings.gradle @@ -1,11 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.7.1" apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false +} + +include ":app"