From fd77a38f971e47333b6eeee9134375a49d123508 Mon Sep 17 00:00:00 2001 From: tk Date: Sun, 17 Aug 2025 05:09:47 +0200 Subject: [PATCH] adapt android build --- wien_talks/wien_talks_flutter/.gitignore | 1 + .../android/app/build.gradle.kts | 50 +++++++++++++++---- .../android/app/proguard-rules.pro | 8 +++ .../lib/screens/show_latest_news_widget.dart | 1 + 4 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 wien_talks/wien_talks_flutter/android/app/proguard-rules.pro diff --git a/wien_talks/wien_talks_flutter/.gitignore b/wien_talks/wien_talks_flutter/.gitignore index 734b7b3..9b5948a 100644 --- a/wien_talks/wien_talks_flutter/.gitignore +++ b/wien_talks/wien_talks_flutter/.gitignore @@ -44,6 +44,7 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release +android/key.properties .env \ No newline at end of file diff --git a/wien_talks/wien_talks_flutter/android/app/build.gradle.kts b/wien_talks/wien_talks_flutter/android/app/build.gradle.kts index c8f71fe..22acb25 100644 --- a/wien_talks/wien_talks_flutter/android/app/build.gradle.kts +++ b/wien_talks/wien_talks_flutter/android/app/build.gradle.kts @@ -1,29 +1,48 @@ +import java.util.Properties +import java.io.FileInputStream + plugins { id("com.android.application") id("kotlin-android") - // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } + +dependencies { + implementation("com.google.android.play:core:1.10.3") +} + +val keystoreProperties = Properties() +val keystorePropertiesFile = rootProject.file("key.properties") +if (keystorePropertiesFile.exists()) { + FileInputStream(keystorePropertiesFile).use { keystoreProperties.load(it) } +} + android { namespace = "com.wien_talks" compileSdk = flutter.compileSdkVersion ndkVersion = flutter.ndkVersion compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } + kotlinOptions { jvmTarget = "17" } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() + signingConfigs { + if (keystorePropertiesFile.exists()) { + create("release") { + keyAlias = keystoreProperties["keyAlias"] as String + keyPassword = keystoreProperties["keyPassword"] as String + val storePath = keystoreProperties["storeFile"] as String? + storeFile = storePath?.let { file(it) } + storePassword = keystoreProperties["storePassword"] as String + } + } } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "com.wien_talks" - // You can update the following values to match your application needs. - // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode @@ -32,9 +51,18 @@ android { 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.getByName("debug") + signingConfig = signingConfigs.findByName("release") + ?: signingConfigs.getByName("debug") + + isMinifyEnabled = true + isShrinkResources = true + + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + debug { } } } diff --git a/wien_talks/wien_talks_flutter/android/app/proguard-rules.pro b/wien_talks/wien_talks_flutter/android/app/proguard-rules.pro new file mode 100644 index 0000000..e2119a7 --- /dev/null +++ b/wien_talks/wien_talks_flutter/android/app/proguard-rules.pro @@ -0,0 +1,8 @@ +-keep class io.flutter.embedding.** { *; } +-keep class io.flutter.plugins.** { *; } +-keep class io.flutter.** { *; } + +-keep class com.google.android.gms.** { *; } +-dontwarn com.google.android.gms.** + +-dontwarn kotlinx.coroutines.** \ No newline at end of file diff --git a/wien_talks/wien_talks_flutter/lib/screens/show_latest_news_widget.dart b/wien_talks/wien_talks_flutter/lib/screens/show_latest_news_widget.dart index 062b24b..af1d361 100644 --- a/wien_talks/wien_talks_flutter/lib/screens/show_latest_news_widget.dart +++ b/wien_talks/wien_talks_flutter/lib/screens/show_latest_news_widget.dart @@ -105,6 +105,7 @@ class _LatestQuotesScreenState extends State { return LayoutBuilder( builder: (context, constraints) { return MasonryGridView.count( + cacheExtent: 20, crossAxisCount: 2, mainAxisSpacing: 8, crossAxisSpacing: 8,