Skip to content

Commit

Permalink
adapt build script to latest flutter status
Browse files Browse the repository at this point in the history
also fixes various build issues
  • Loading branch information
dreautall committed Nov 12, 2024
1 parent 52db70f commit 7922cc0
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 81 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ migrate_working_dir/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
Expand Down
33 changes: 33 additions & 0 deletions .idx/dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ pkgs }: {
channel = "stable-23.11";
packages = [
pkgs.nodePackages.firebase-tools
pkgs.jdk17
pkgs.unzip
];
idx.extensions = [
"dart-code.dart-code"
"dart-code.flutter"
"google.arb-editor"
"github.vscode-github-actions"
"github.vscode-pull-request-github"
"eamodio.gitlens"
"jock.svg"
];
idx.previews = {
previews = {
android = {
command = [
"flutter"
"run"
"--machine"
"-d"
"android"
"-d"
"emulator-5554"
];
manager = "flutter";
};
};
};
}
2 changes: 1 addition & 1 deletion android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gradle-wrapper.jar
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
61 changes: 35 additions & 26 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
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()) {
Expand All @@ -20,7 +21,7 @@ if (flutterVersionCode == null) {
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
}*/

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
Expand All @@ -29,33 +30,33 @@ if (keystorePropertiesFile.exists()) {
}

android {
namespace = 'com.dreautall.waterflyiii'
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

// Added: flutter_local_notifications
coreLibraryDesugaringEnabled true
}

kotlinOptions {
jvmTarget = '11'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
jvmTarget = JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.dreautall.waterflyiii"
applicationId 'com.dreautall.waterflyiii'
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
minSdk = 21
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName

// Added: flutter_local_notifications
multiDexEnabled true
}

signingConfigs {
Expand All @@ -70,7 +71,7 @@ android {
debug {
minifyEnabled false
shrinkResources false
applicationIdSuffix ".debug"
applicationIdSuffix '.debug'
}

release {
Expand All @@ -96,6 +97,13 @@ flutter {
source '../..'
}

// Added: flutter_local_notifications
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
}
/*
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0"
implementation 'com.google.android.material:material:1.8.0'
Expand All @@ -104,15 +112,16 @@ dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.2' // Added: flutter_local_notifications
implementation 'androidx.window:window:1.1.0-rc01' // Added: flutter_local_notifications
implementation 'androidx.window:window-java:1.1.0-rc01' // Added: flutter_local_notifications
}
}*/

ext.abiCodes = ["x86_64": 1, "armeabi-v7a": 2, "arm64-v8a": 3]
ext.abiCodes = ['x86_64': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3]
import com.android.build.OutputFile

android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def abiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (abiVersionCode != null) {
output.versionCodeOverride = variant.versionCode * 10 + abiVersionCode
variant.outputs.each { output ->
def abiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (abiVersionCode != null) {
output.versionCodeOverride = variant.versionCode * 10 + abiVersionCode
}
}
}
}
}
44 changes: 41 additions & 3 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
-keep class java.net.URL { *; }
-keep class java.util.concurrent.Executors { *; }
-keep class org.chromium.net.** { *; }
# Added: flutter_local_notifications
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

##---------------End: proguard configuration for Gson ----------

# https://github.com/mogol/flutter_secure_storage/issues/748
-dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue
-dontwarn com.google.errorprone.annotations.CheckReturnValue
-dontwarn com.google.errorprone.annotations.Immutable
-dontwarn com.google.errorprone.annotations.RestrictedApi
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.concurrent.GuardedBy
28 changes: 11 additions & 17 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.dreautall.waterflyiii">
<application
android:label="Waterfly III"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:enableOnBackInvokedCallback="true"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
>
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
>
<application android:label="Waterfly III" android:name="${applicationName}" android:icon="@mipmap/ic_launcher" android:enableOnBackInvokedCallback="true" android:usesCleartextTraffic="true" android:networkSecurityConfig="@xml/network_security_config">
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:taskAffinity="" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down Expand Up @@ -53,6 +38,15 @@

<!-- Queries, used by url_launcher -->
<queries>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
Expand Down
37 changes: 14 additions & 23 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,28 @@ allprojects {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'

// see https://github.com/flutter/flutter/issues/153281#issuecomment-2292201697
subprojects {
afterEvaluate { project ->
if (project.extensions.findByName("android") != null) {
Integer pluginCompileSdk = project.android.compileSdk
if (pluginCompileSdk != null && pluginCompileSdk < 31) {
project.logger.error(
"Warning: Overriding compileSdk version in Flutter plugin: "
+ project.name
+ " from "
+ pluginCompileSdk
+ " to 31 (to work around https://issuetracker.google.com/issues/199180389)."
+ "\nIf there is not a new version of " + project.name + ", consider filing an issue against "
+ project.name
+ " to increase their compileSdk to the latest (otherwise try updating to the latest version)."
)
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
compileSdk 31
if (namespace == null) {
namespace project.group
}
}
}
}
}

}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(":app")
}
subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
5 changes: 2 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1024M
org.gradle.caching=true
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
9 changes: 4 additions & 5 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ pluginManagement {
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()
}()

includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
Expand All @@ -19,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.4.2" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: waterflyiii
description: WaterFly III, a mobile client for Firefly III
description: Waterfly III, a mobile client for Firefly III
publish_to: 'none'

version: 1.0.9
Expand Down

0 comments on commit 7922cc0

Please sign in to comment.