Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix examples for JDK 21 (Android Studio Ladybug) #695

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,32 @@ jobs:
- ubuntu-24.04
- windows-2022 # Flutter 2.9 and newer need Visual Studio 2022 to build desktop.
flutter-version:
# Include lowest working version (use lowest tested Dart SDK as a guideline, see lib tests
# above; but may be higher due to dependency conflicts)
# Include lowest working version supported by examples;
# https://docs.flutter.dev/development/tools/sdk/releases lists included Dart SDK.
- 3.24.2
- 3.7.12
- 3.16.9
include:
# Building for Android (currently only on Linux, see integration-test.sh):
# build with highest supported JDK on latest Flutter SDK,
# lowest supported JDK on lowest supported Flutter SDK.
- os: ubuntu-24.04
flutter-version: 3.24.2
jdk: 21
- os: ubuntu-24.04
flutter-version: 3.16.9
jdk: 17
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2.16.0
with:
flutter-version: ${{ matrix.flutter-version }}
cache: true
# windows-2022 defaults to Java 8, but Android Plugin requires at least 11.
- uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
- if: ${{ matrix.jdk }}
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
distribution: 'temurin'
java-version: '17'
java-version: ${{ matrix.jdk }}
- run: echo $PATH
- run: flutter --version
# https://docs.flutter.dev/desktop#additional-linux-requirements
Expand Down
32 changes: 16 additions & 16 deletions .gitlab/merge_request_templates/Default.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
## What does this merge request do?

Addresses #NUMBER+
<!-- TODO Link associated issue from title, like: <title> #NUMBER -->

<!-- Briefly describe what this merge request is about. -->
<!-- TODO Briefly list what this merge request is about -->

## Author's checklist

- [ ] The merge request fully addresses the requirements of the associated task.
- [ ] I did a self-review of the changes and did not spot any issues. Among others, this includes:
* I added unit tests for new/changed behavior; all test pass.
* My code conforms to our coding standards and guidelines.
* My changes are prepared in a way that makes the review straightforward for the reviewer.
- [ ] I amended [`CHANGELOG.md`](objectbox/CHANGELOG.md) if this affects users in any way.
- [ ] I assigned a reviewer and added the Review label.
- [ ] This merge request fully addresses the requirements of the associated task
- [ ] I did a self-review of the changes and did not spot any issues, among others:
- I added unit tests for new or changed behavior; existing and new tests pass
- My code conforms to our coding standards and guidelines
- My changes are prepared (focused commits, good messages) so reviewing them is easy for the reviewer
- [ ] I amended the [changelog](/objectbox/CHANGELOG.md) if this affects users in any way
- [ ] I assigned a reviewer to request review

## Review checklist
## Reviewer's checklist

- [ ] I reviewed all changes line-by-line and addressed relevant issues
- [ ] I reviewed all changes line-by-line and addressed relevant issues
- [ ] The requirements of the associated task are fully met
- [ ] I can confirm that:
* CI passes
* Coverage percentages do not decrease
* New code conforms to standards and guidelines
* If applicable, additional checks were done for special code changes (e.g. core performance, binary size, OSS licenses)
- [ ] I can confirm that:
- CI passes
- If applicable, coverage percentages do not decrease
- New code conforms to standards and guidelines
- If applicable, additional checks were done for special code changes (e.g. core performance, binary size, OSS licenses)
32 changes: 24 additions & 8 deletions dev-doc/updating-examples.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
# Updating Flutter examples

First, make sure to switch your Flutter SDK to the lowest version the ObjectBox packages support
(see pubspec.yaml files).
First, make sure to switch your Flutter SDK to the lowest version that should be supported
(at minimum what the Flutter packages require, see their pubspec.yaml files; but typically higher
due to dependency or tooling requirements):

Then, in the example directory delete the platform-specific directories.
```shell
# Make sure to close IDEs or tools using the Flutter or Dart SDK first.
# Then, in the Flutter SDK directory:
git checkout <version>
flutter doctor
```

Then, run `flutter create --platforms=android,ios,linux,macos,windows .` to re-create these files.
Then, for an example in its directory delete the platform-specific directories and the

Then, remove the created default test files and manually review the changes and commit what's necessary.
- `.gitignore`
- `analysis_options.yaml`
- `pubspec.yaml`

Check changes do not break the example in any way, make additional changes as required.
files.

Compare against a clean Flutter template (run `create` in an empty folder) to see if updates to
other files like pubspec.yaml are needed.
Then, run `flutter create --platforms=android,ios,linux,macos,windows .` to create empty example
files.

Then, remove the created default widget test file. Review the changes, restore any required changes
(like in Podfile, build scripts, project files, the files mentioned above...). This can be helped by
running `flutter pub upgrade` and `flutter run` on each platform (with the same Flutter SDK version!).

Then, commit only what's necessary.

Then, adjust the other examples accordingly.
3 changes: 3 additions & 0 deletions objectbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## latest

* Examples: demos are compatible with Android Studio Ladybug and JDK 21, require Flutter SDK 3.16.9
(with Dart SDK 3.2.6) or newer.

## 4.0.3 (2024-10-17)

* Generator: replace cryptography library, allows to use newer versions of the transitive `js` dependency. [#638](https://github.com/objectbox/objectbox-dart/issues/638)
Expand Down
6 changes: 0 additions & 6 deletions objectbox/example/flutter/objectbox_demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ migrate_working_dir/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

Expand All @@ -46,8 +42,6 @@ app.*.map.json
/android/app/profile
/android/app/release

objectbox

# Not checking in Podfile.lock to avoid updating it for every
# ObjectBox release and to always build with latest dependencies on CI.
ios/Podfile.lock
Expand Down
30 changes: 15 additions & 15 deletions objectbox/example/flutter/objectbox_demo/.metadata
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 135454af32477f815a7525073027a3ff9eff1bfd
channel: unknown
revision: "41456452f29d64e8deb623a3c927524bcf9f111b"
channel: "[user-branch]"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: android
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: ios
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: linux
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: macos
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: windows
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b

# User provided section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
Expand Down
35 changes: 20 additions & 15 deletions objectbox/example/flutter/objectbox_demo/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,13 +22,19 @@ 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 {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
namespace "com.example.objectbox_demo"
// ObjectBox: set compileSdkVersion 34 for path_provider_android plugin;
// this can be removed once minimum tested Flutter version is 3.19.0.
// compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 34
// ObjectBox: Flutter defaults to NDK 23.1.7779620, but
// - objectbox_flutter_libs requires Android NDK 25.1.8937393
// - path_provider_android requires Android NDK 25.1.8937393
// Until Flutter uses a newer version (https://github.com/flutter/flutter/commit/919bed6e0a18bd5b76fb581ede10121f8c14a6f7)
// manually set the required one:
// ndkVersion flutter.ndkVersion
ndkVersion = "25.1.8937393"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -45,9 +52,8 @@ android {
defaultConfig {
applicationId "com.example.objectbox_demo"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
// minSdkVersion flutter.minSdkVersion
minSdkVersion 19 // ObjectBox requires at least SDK 19 (Android 4.4)
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand All @@ -67,5 +73,4 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.objectbox_demo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.objectbox_demo">
<application
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="objectbox_demo"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.objectbox_demo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
buildscript {
ext.kotlin_version = '1.7.0'
ext.kotlin_version = '1.9.24' // 1.7.10 -> 1.9.24 to get 1.9 metadata version
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx4G
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
34 changes: 26 additions & 8 deletions objectbox/example/flutter/objectbox_demo/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
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
}
settings.ext.flutterSdkPath = flutterSdkPath()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("${settings.ext.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-gradle-plugin" version "1.0.0" apply false
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.2.1" apply false // 7.3.0 -> 8.2.1 to support JDK 21
}

include ":app"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
3 changes: 3 additions & 0 deletions objectbox/example/flutter/objectbox_demo/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ target 'Runner' do
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
Expand Down
Loading
Loading