Skip to content

Commit dfee86c

Browse files
authored
fix: avoid reopening root when using multiple FlutterEngines (#153)
1 parent ae1f0f5 commit dfee86c

25 files changed

+157
-158
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ Many thanks to my sponsors, no matter how much or how little they donated. Spons
1414

1515
# Changelog
1616

17-
## [9.0.0] - "Just Another Rewrite" - 2024/04/XX
17+
## [9.0.1] - 2024/04/29
18+
19+
* Fixed bug on initialisation, where using multiple/background `FlutterEngine`s would attempt to re-open a single ObjectBox Store (aka. root) multiple times
20+
21+
## [9.0.0] - "Just Another Rewrite" - 2024/04/11
1822

1923
This update has essentially rewritten FMTC from the ground up, over hundreds of hours. It focuses on:
2024

example/.metadata

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "2524052335ec76bb03e04ede244b071f1b86d190"
8-
channel: "stable"
7+
revision: "29babcb32a591b9e5be8c6a6075d4fe605d46ad3"
8+
channel: "beta"
99

1010
project_type: app
1111

1212
# Tracks metadata for the flutter migrate command
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 2524052335ec76bb03e04ede244b071f1b86d190
17-
base_revision: 2524052335ec76bb03e04ede244b071f1b86d190
18-
- platform: windows
19-
create_revision: 2524052335ec76bb03e04ede244b071f1b86d190
20-
base_revision: 2524052335ec76bb03e04ede244b071f1b86d190
16+
create_revision: 29babcb32a591b9e5be8c6a6075d4fe605d46ad3
17+
base_revision: 29babcb32a591b9e5be8c6a6075d4fe605d46ad3
18+
- platform: android
19+
create_revision: 29babcb32a591b9e5be8c6a6075d4fe605d46ad3
20+
base_revision: 29babcb32a591b9e5be8c6a6075d4fe605d46ad3
2121

2222
# User provided section
2323

example/android/app/build.gradle

+25-49
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,53 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id "dev.flutter.flutter-gradle-plugin"
6+
}
7+
18
def localProperties = new Properties()
2-
def localPropertiesFile = rootProject.file('local.properties')
9+
def localPropertiesFile = rootProject.file("local.properties")
310
if (localPropertiesFile.exists()) {
4-
localPropertiesFile.withReader('UTF-8') { reader ->
11+
localPropertiesFile.withReader("UTF-8") { reader ->
512
localProperties.load(reader)
613
}
714
}
815

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
14-
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
16+
def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
1517
if (flutterVersionCode == null) {
16-
flutterVersionCode = '9'
18+
flutterVersionCode = "9"
1719
}
1820

19-
def flutterVersionName = localProperties.getProperty('flutter.versionName')
21+
def flutterVersionName = localProperties.getProperty("flutter.versionName")
2022
if (flutterVersionName == null) {
21-
flutterVersionName = '9.0.0'
22-
}
23-
24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
28-
def keystoreProperties = new Properties()
29-
def keystorePropertiesFile = rootProject.file('key.properties')
30-
if (keystorePropertiesFile.exists()) {
31-
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
23+
flutterVersionName = "9.0"
3224
}
3325

3426
android {
35-
compileSdkVersion rootProject.ext.compileSdkVersion
36-
37-
defaultConfig {
38-
multiDexEnabled true
39-
}
27+
namespace = "dev.jaffaketchup.fmtc.demo"
28+
compileSdk = flutter.compileSdkVersion
29+
ndkVersion = flutter.ndkVersion
4030

4131
compileOptions {
42-
coreLibraryDesugaringEnabled true
43-
sourceCompatibility JavaVersion.VERSION_1_8
44-
targetCompatibility JavaVersion.VERSION_1_8
45-
}
46-
47-
kotlinOptions {
48-
jvmTarget = '1.8'
49-
}
50-
51-
sourceSets {
52-
main.java.srcDirs += 'src/main/kotlin'
32+
sourceCompatibility = JavaVersion.VERSION_1_8
33+
targetCompatibility = JavaVersion.VERSION_1_8
5334
}
5435

5536
defaultConfig {
56-
applicationId "dev.jaffaketchup.fmtc.demo"
57-
minSdkVersion rootProject.ext.minSdkVersion
58-
targetSdkVersion rootProject.ext.targetSdkVersion
59-
versionCode flutterVersionCode.toInteger()
60-
versionName flutterVersionName
37+
applicationId = "dev.jaffaketchup.fmtc.demo"
38+
minSdk = flutter.minSdkVersion
39+
targetSdk = flutter.targetSdkVersion
40+
versionCode = flutterVersionCode.toInteger()
41+
versionName = flutterVersionName
6142
}
6243

6344
buildTypes {
6445
release {
65-
signingConfig signingConfigs.debug
46+
signingConfig = signingConfigs.debug
6647
}
6748
}
6849
}
6950

7051
flutter {
71-
source '../..'
72-
}
73-
74-
dependencies {
75-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
76-
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
52+
source = "../.."
7753
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="dev.jaffaketchup.fmtc.demo">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<uses-permission android:name="android.permission.INTERNET"/>
4-
<queries>
5-
<intent>
6-
<action android:name="android.intent.action.VIEW" />
7-
<data android:scheme="https" />
8-
</intent>
9-
</queries>
103
</manifest>
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="dev.jaffaketchup.fmtc.demo">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<uses-permission android:name="android.permission.INTERNET"/>
43
<application
54
android:label="FMTC Demo"
5+
android:name="${applicationName}"
66
android:icon="@mipmap/ic_launcher">
77
<activity
88
android:name=".MainActivity"
9+
android:exported="true"
910
android:launchMode="singleTop"
11+
android:taskAffinity=""
1012
android:theme="@style/LaunchTheme"
1113
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1214
android:hardwareAccelerated="true"
1315
android:windowSoftInputMode="adjustResize">
16+
<!-- Specifies an Android theme to apply to this Activity as soon as
17+
the Android process has started. This theme is visible to the user
18+
while the Flutter UI initializes. After that, this theme continues
19+
to determine the Window background behind the Flutter UI. -->
1420
<meta-data
1521
android:name="io.flutter.embedding.android.NormalTheme"
1622
android:resource="@style/NormalTheme"
@@ -20,14 +26,21 @@
2026
<category android:name="android.intent.category.LAUNCHER"/>
2127
</intent-filter>
2228
</activity>
29+
<!-- Don't delete the meta-data below.
30+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
2331
<meta-data
2432
android:name="flutterEmbedding"
2533
android:value="2" />
2634
</application>
35+
<!-- Required to query activities that can process text, see:
36+
https://developer.android.com/training/package-visibility and
37+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
38+
39+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
2740
<queries>
2841
<intent>
29-
<action android:name="android.intent.action.VIEW" />
30-
<data android:scheme="https" />
42+
<action android:name="android.intent.action.PROCESS_TEXT"/>
43+
<data android:mimeType="text/plain"/>
3144
</intent>
32-
</queries>
45+
</queries>
3346
</manifest>

example/android/app/src/main/kotlin/dev/org/fmtc/example/fmtc_example/MainActivity.kt renamed to example/android/app/src/main/kotlin/com/example/example/MainActivity.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ package dev.jaffaketchup.fmtc.demo
22

33
import io.flutter.embedding.android.FlutterActivity
44

5-
class MainActivity: FlutterActivity() {
6-
}
5+
class MainActivity: FlutterActivity()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

example/android/app/src/main/res/values-night/styles.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
44
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
55
<!-- Show a splash screen on the activity. Automatically removed when
6-
Flutter draws its first frame -->
6+
the Flutter engine draws its first frame -->
77
<item name="android:windowBackground">@drawable/launch_background</item>
88
</style>
99
<!-- Theme applied to the Android Window as soon as the process has started.
1010
This theme determines the color of the Android Window while your
1111
Flutter UI initializes, as well as behind your Flutter UI while its
1212
running.
13-
13+
1414
This Theme is only used starting with V2 of Flutter's Android embedding. -->
1515
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
1616
<item name="android:windowBackground">?android:colorBackground</item>

example/android/app/src/main/res/values/styles.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
44
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
55
<!-- Show a splash screen on the activity. Automatically removed when
6-
Flutter draws its first frame -->
6+
the Flutter engine draws its first frame -->
77
<item name="android:windowBackground">@drawable/launch_background</item>
88
</style>
99
<!-- Theme applied to the Android Window as soon as the process has started.
1010
This theme determines the color of the Android Window while your
1111
Flutter UI initializes, as well as behind your Flutter UI while its
1212
running.
13-
13+
1414
This Theme is only used starting with V2 of Flutter's Android embedding. -->
1515
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
1616
<item name="android:windowBackground">?android:colorBackground</item>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="dev.jaffaketchup.fmtc.demo">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<uses-permission android:name="android.permission.INTERNET"/>
4-
<queries>
5-
<intent>
6-
<action android:name="android.intent.action.VIEW" />
7-
<data android:scheme="https" />
8-
</intent>
9-
</queries>
103
</manifest>

example/android/build.gradle

+16-24
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
buildscript {
2-
ext {
3-
kotlin_version = '1.8.21'
4-
gradle_version = '7.4.0'
5-
6-
compileSdkVersion = 33
7-
targetSdkVersion = 29
8-
minSdkVersion = 23
9-
appCompatVersion = "1.1.0"
10-
}
11-
1+
allprojects {
122
repositories {
133
google()
144
mavenCentral()
155
}
16-
17-
dependencies {
18-
classpath "com.android.tools.build:gradle:$gradle_version"
19-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20-
}
216
}
227

23-
allprojects {
24-
repositories {
25-
google()
26-
mavenCentral()
8+
rootProject.buildDir = "../build"
9+
10+
subprojects {
11+
afterEvaluate { project ->
12+
if (project.hasProperty('android')) {
13+
project.android {
14+
if (namespace == null) {
15+
namespace project.group
16+
}
17+
}
18+
}
2719
}
20+
21+
project.buildDir = "${rootProject.buildDir}/${project.name}"
2822
}
2923

30-
rootProject.buildDir = '../build'
3124
subprojects {
32-
project.buildDir = "${rootProject.buildDir}/${project.name}"
33-
project.evaluationDependsOn(':app')
25+
project.evaluationDependsOn(":app")
3426
}
3527

3628
tasks.register("clean", Delete) {
3729
delete rootProject.buildDir
38-
}
30+
}

example/android/gradle.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
org.gradle.jvmargs=-Xmx1536M
1+
org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true
4+
android.defaults.buildfeatures.buildconfig=true
5+
android.nonTransitiveRClass=false
6+
android.nonFinalResIds=false

example/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip

example/android/settings.gradle

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version '8.0.1' apply false
22+
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
23+
}
24+
25+
include ":app"

example/pubspec.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: The example application for 'flutter_map_tile_caching', showcasing
33
it's functionality and use-cases.
44
publish_to: "none"
55

6-
version: 9.0.0
6+
version: 9.0.1
77

88
environment:
99
sdk: ">=3.3.0 <4.0.0"
@@ -15,10 +15,9 @@ dependencies:
1515
better_open_file: ^3.6.5
1616
collection: ^1.18.0
1717
dart_earcut: ^1.1.0
18-
file_picker: ^8.0.0+1
18+
file_picker: ^8.0.3
1919
flutter:
2020
sdk: flutter
21-
flutter_foreground_task: ^6.1.3
2221
flutter_map: ^6.1.0
2322
flutter_map_animations: ^0.6.0
2423
flutter_map_tile_caching:
@@ -29,7 +28,7 @@ dependencies:
2928
latlong2: ^0.9.1
3029
osm_nominatim: ^3.0.0
3130
path: ^1.9.0
32-
path_provider: ^2.1.2
31+
path_provider: ^2.1.3
3332
provider: ^6.1.2
3433
stream_transform: ^2.1.0
3534
validators: ^3.0.0

0 commit comments

Comments
 (0)