Skip to content

Commit 73dc57d

Browse files
Demos: update Android template, incl. Android plugin.
1 parent 5168092 commit 73dc57d

File tree

13 files changed

+90
-82
lines changed

13 files changed

+90
-82
lines changed

objectbox/example/flutter/objectbox_demo/android/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
key.properties
12+
**/*.keystore
13+
**/*.jks

objectbox/example/flutter/objectbox_demo/android/app/build.gradle

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,27 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 28
29+
compileSdkVersion 29
3030

31-
sourceSets {
32-
main.java.srcDirs += 'src/main/kotlin'
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_8
33+
targetCompatibility JavaVersion.VERSION_1_8
34+
}
35+
36+
kotlinOptions {
37+
jvmTarget = '1.8'
3338
}
3439

35-
lintOptions {
36-
disable 'InvalidPackage'
40+
sourceSets {
41+
main.java.srcDirs += 'src/main/kotlin'
3742
}
3843

3944
defaultConfig {
4045
applicationId "com.example.objectbox_demo"
4146
minSdkVersion 16
42-
targetSdkVersion 28
47+
targetSdkVersion 29
4348
versionCode flutterVersionCode.toInteger()
4449
versionName flutterVersionName
45-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4650
}
4751

4852
buildTypes {
@@ -60,7 +64,4 @@ flutter {
6064

6165
dependencies {
6266
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
63-
testImplementation 'junit:junit:4.12'
64-
androidTestImplementation 'androidx.test:runner:1.1.1'
65-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
6667
}

objectbox/example/flutter/objectbox_demo/android/app/src/main/AndroidManifest.xml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,39 @@
33
<application
44
android:label="objectbox_demo"
55
android:icon="@mipmap/ic_launcher">
6-
7-
<meta-data
8-
android:name="flutterEmbedding"
9-
android:value="2" />
10-
116
<activity
127
android:name=".MainActivity"
138
android:launchMode="singleTop"
149
android:theme="@style/LaunchTheme"
1510
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1611
android:hardwareAccelerated="true"
1712
android:windowSoftInputMode="adjustResize">
18-
<!-- Specify that the launch screen should continue being displayed -->
19-
<!-- until Flutter renders its first frame. -->
13+
<!-- Specifies an Android theme to apply to this Activity as soon as
14+
the Android process has started. This theme is visible to the user
15+
while the Flutter UI initializes. After that, this theme continues
16+
to determine the Window background behind the Flutter UI. -->
2017
<meta-data
21-
android:name="io.flutter.embedding.android.SplashScreenDrawable"
22-
android:resource="@drawable/launch_background" />
23-
24-
<!-- Theme to apply as soon as Flutter begins rendering frames -->
18+
android:name="io.flutter.embedding.android.NormalTheme"
19+
android:resource="@style/NormalTheme"
20+
/>
21+
<!-- Displays an Android View that continues showing the launch screen
22+
Drawable until Flutter paints its first frame, then this splash
23+
screen fades out. A splash screen is useful to avoid any visual
24+
gap between the end of Android's launch screen and the painting of
25+
Flutter's first frame. -->
2526
<meta-data
26-
android:name="io.flutter.embedding.android.NormalTheme"
27-
android:resource="@style/NormalTheme" />
27+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
28+
android:resource="@drawable/launch_background"
29+
/>
2830
<intent-filter>
2931
<action android:name="android.intent.action.MAIN"/>
3032
<category android:name="android.intent.category.LAUNCHER"/>
3133
</intent-filter>
3234
</activity>
35+
<!-- Don't delete the meta-data below.
36+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
37+
<meta-data
38+
android:name="flutterEmbedding"
39+
android:value="2" />
3340
</application>
3441
</manifest>

objectbox/example/flutter/objectbox_demo/android/build.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@ buildscript {
22
ext.kotlin_version = '1.3.50'
33
repositories {
44
google()
5-
jcenter()
5+
mavenCentral()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath 'com.android.tools.build:gradle:4.1.0'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}
1313

1414
allprojects {
1515
repositories {
1616
google()
17-
jcenter()
17+
mavenCentral()
1818
}
1919
}
2020

2121
rootProject.buildDir = '../build'
2222
subprojects {
2323
project.buildDir = "${rootProject.buildDir}/${project.name}"
24-
}
25-
subprojects {
2624
project.evaluationDependsOn(':app')
2725
}
2826

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2-
android.enableR8=true
32
android.useAndroidX=true
43
android.enableJetifier=true

objectbox/example/flutter/objectbox_demo/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
include ':app'
22

3-
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
3+
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4+
def properties = new Properties()
45

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9-
}
6+
assert localPropertiesFile.exists()
7+
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
108

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
15-
}
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"

objectbox/example/flutter/objectbox_demo_sync/android/app/build.gradle

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,27 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 28
29+
compileSdkVersion 29
3030

31-
sourceSets {
32-
main.java.srcDirs += 'src/main/kotlin'
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_8
33+
targetCompatibility JavaVersion.VERSION_1_8
34+
}
35+
36+
kotlinOptions {
37+
jvmTarget = '1.8'
3338
}
3439

35-
lintOptions {
36-
disable 'InvalidPackage'
40+
sourceSets {
41+
main.java.srcDirs += 'src/main/kotlin'
3742
}
3843

3944
defaultConfig {
4045
applicationId "com.example.objectbox_demo"
4146
minSdkVersion 21
42-
targetSdkVersion 28
47+
targetSdkVersion 29
4348
versionCode flutterVersionCode.toInteger()
4449
versionName flutterVersionName
45-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4650
}
4751

4852
buildTypes {
@@ -60,7 +64,4 @@ flutter {
6064

6165
dependencies {
6266
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
63-
testImplementation 'junit:junit:4.12'
64-
androidTestImplementation 'androidx.test:runner:1.1.1'
65-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
6667
}

objectbox/example/flutter/objectbox_demo_sync/android/app/src/main/AndroidManifest.xml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,39 @@
33
<application
44
android:label="objectbox_demo"
55
android:icon="@mipmap/ic_launcher">
6-
7-
<meta-data
8-
android:name="flutterEmbedding"
9-
android:value="2" />
10-
116
<activity
127
android:name=".MainActivity"
138
android:launchMode="singleTop"
149
android:theme="@style/LaunchTheme"
1510
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1611
android:hardwareAccelerated="true"
1712
android:windowSoftInputMode="adjustResize">
18-
<!-- Specify that the launch screen should continue being displayed -->
19-
<!-- until Flutter renders its first frame. -->
13+
<!-- Specifies an Android theme to apply to this Activity as soon as
14+
the Android process has started. This theme is visible to the user
15+
while the Flutter UI initializes. After that, this theme continues
16+
to determine the Window background behind the Flutter UI. -->
2017
<meta-data
21-
android:name="io.flutter.embedding.android.SplashScreenDrawable"
22-
android:resource="@drawable/launch_background" />
23-
24-
<!-- Theme to apply as soon as Flutter begins rendering frames -->
18+
android:name="io.flutter.embedding.android.NormalTheme"
19+
android:resource="@style/NormalTheme"
20+
/>
21+
<!-- Displays an Android View that continues showing the launch screen
22+
Drawable until Flutter paints its first frame, then this splash
23+
screen fades out. A splash screen is useful to avoid any visual
24+
gap between the end of Android's launch screen and the painting of
25+
Flutter's first frame. -->
2526
<meta-data
26-
android:name="io.flutter.embedding.android.NormalTheme"
27-
android:resource="@style/NormalTheme" />
27+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
28+
android:resource="@drawable/launch_background"
29+
/>
2830
<intent-filter>
2931
<action android:name="android.intent.action.MAIN"/>
3032
<category android:name="android.intent.category.LAUNCHER"/>
3133
</intent-filter>
3234
</activity>
35+
<!-- Don't delete the meta-data below.
36+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
37+
<meta-data
38+
android:name="flutterEmbedding"
39+
android:value="2" />
3340
</application>
3441
</manifest>

objectbox/example/flutter/objectbox_demo_sync/android/build.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@ buildscript {
22
ext.kotlin_version = '1.3.50'
33
repositories {
44
google()
5-
jcenter()
5+
mavenCentral()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath 'com.android.tools.build:gradle:4.1.0'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}
1313

1414
allprojects {
1515
repositories {
1616
google()
17-
jcenter()
17+
mavenCentral()
1818
}
1919
}
2020

2121
rootProject.buildDir = '../build'
2222
subprojects {
2323
project.buildDir = "${rootProject.buildDir}/${project.name}"
24-
}
25-
subprojects {
2624
project.evaluationDependsOn(':app')
2725
}
2826

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2-
android.enableR8=true
32
android.useAndroidX=true
43
android.enableJetifier=true

objectbox/example/flutter/objectbox_demo_sync/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
include ':app'
22

3-
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
3+
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4+
def properties = new Properties()
45

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9-
}
6+
assert localPropertiesFile.exists()
7+
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
108

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
15-
}
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"

0 commit comments

Comments
 (0)