Skip to content

Commit a4544d0

Browse files
committed
chore: update Android Gradle build to support the newer Flutter SDK
- Upgraded Gradle to 8.12.1 - Changed compile and target compatibility to Java 17 - Set `compileSdkVersion` to use Flutter's value. - Added compiler flags for unchecked and deprecation warnings.
1 parent 53a0c2a commit a4544d0

File tree

8 files changed

+39
-32
lines changed

8 files changed

+39
-32
lines changed

.github/workflows/flutter_integration.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ on:
77

88
jobs:
99
ios:
10-
strategy:
11-
matrix:
12-
device: # Device names must be shown in `xcrun simctl list devices`
13-
- 'iPhone 15' # we are not specifying the iOS version as it tends to change
14-
fail-fast: false
1510
runs-on: macos-latest
1611
steps:
1712
- uses: actions/checkout@v4
@@ -22,7 +17,7 @@ jobs:
2217

2318
- uses: subosito/flutter-action@v2
2419
with:
25-
flutter-version: '3.24'
20+
flutter-version: '3.29'
2621
cache: true
2722

2823
# test_integration package depends on ably_flutter, so before we run integration
@@ -58,7 +53,7 @@ jobs:
5853
5954
- uses: subosito/flutter-action@v2
6055
with:
61-
flutter-version: '3.24'
56+
flutter-version: '3.29'
6257
cache: true
6358

6459
- name: 'Run Flutter Driver tests'
@@ -70,4 +65,4 @@ jobs:
7065
disable-animations: true
7166
script: |
7267
flutter pub get
73-
cd test_integration && flutter drive
68+
cd test_integration && flutter build apk && flutter drive

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ruby 3.0.1
1+
ruby 3.4.5
22
flutter 3.29.0

android/build.gradle

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
group 'io.ably.flutter.plugin'
2-
version '1.0'
2+
// Use the snapshot suffix to show that build artifacts are not shared.
3+
// This Gradle file is used by Flutter to build itself.
4+
version '1.0-SNAPSHOT'
35

46
buildscript {
57
repositories {
68
google()
7-
mavenCentral() // for firebase-messaging
9+
mavenCentral()
810
}
911

1012
dependencies {
11-
classpath 'com.android.tools.build:gradle:7.4.0'
13+
classpath 'com.android.tools.build:gradle:8.12.1'
1214
}
1315
}
1416

@@ -23,35 +25,31 @@ apply plugin: 'com.android.library'
2325

2426
dependencies {
2527
// https://github.com/ably/ably-java/
26-
implementation 'io.ably:ably-android:1.2.40'
28+
implementation 'io.ably:ably-android:1.4.1'
2729

2830
// https://firebase.google.com/docs/cloud-messaging/android/client
29-
implementation 'com.google.firebase:firebase-messaging:23.0.4'
31+
implementation 'com.google.firebase:firebase-messaging:23.0.6'
3032

3133
// https://github.com/google/desugar_jdk_libs
3234
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
3335
}
3436

3537
android {
36-
compileSdkVersion 34
38+
// older version of flutter sdk doesn't provide `compileSdkVersion` defaults to 34
39+
compileSdkVersion flutter.compileSdkVersion ?: 34
3740

3841
// Conditional for compatibility with AGP <4.2.
3942
if (project.android.hasProperty("namespace")) {
4043
namespace 'io.ably.flutter.plugin'
4144
}
4245

43-
// Require Java language level 8 so we can use Method References (used with Lambdas)
4446
compileOptions {
45-
sourceCompatibility JavaVersion.VERSION_1_8
46-
targetCompatibility JavaVersion.VERSION_1_8
47-
48-
// Flag to enable Java 8 language APIs while supporting to older SDK Versions
49-
coreLibraryDesugaringEnabled true
47+
sourceCompatibility = JavaVersion.VERSION_17
48+
targetCompatibility = JavaVersion.VERSION_17
5049
}
5150

5251
defaultConfig {
5352
minSdkVersion 19
54-
5553
// Required when setting minSdkVersion to 20 or lower so we can use
5654
// the Java 8 language APIs as mentioned here:
5755
// https://developer.android.com/studio/write/java8-support#library-desugaring
@@ -66,4 +64,10 @@ android {
6664
}
6765
}
6866

67+
gradle.projectsEvaluated {
68+
tasks.withType(JavaCompile) {
69+
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
70+
}
71+
}
72+
6973
apply from: file("./ably-agent.gradle")

example/android/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ android {
1414
compileOptions {
1515
coreLibraryDesugaringEnabled true
1616

17-
sourceCompatibility = JavaVersion.VERSION_1_8
18-
targetCompatibility = JavaVersion.VERSION_1_8
17+
sourceCompatibility = JavaVersion.VERSION_17
18+
targetCompatibility = JavaVersion.VERSION_17
1919
}
2020

2121
kotlinOptions {
22-
jvmTarget = JavaVersion.VERSION_1_8
22+
jvmTarget = JavaVersion.VERSION_17
2323
}
2424

2525
defaultConfig {

example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pluginManagement {
1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
2121
id "com.android.application" version "8.7.0" apply false
22-
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
22+
id "org.jetbrains.kotlin.android" version "2.2.20" apply false
2323
id "com.google.gms.google-services" version "4.3.10" apply false
2424
}
2525

test_integration/android/app/build.gradle

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ android {
1111
ndkVersion = flutter.ndkVersion
1212

1313
compileOptions {
14-
sourceCompatibility = JavaVersion.VERSION_1_8
15-
targetCompatibility = JavaVersion.VERSION_1_8
14+
coreLibraryDesugaringEnabled true
15+
16+
sourceCompatibility = JavaVersion.VERSION_17
17+
targetCompatibility = JavaVersion.VERSION_17
1618
}
1719

1820
kotlinOptions {
19-
jvmTarget = JavaVersion.VERSION_1_8
21+
jvmTarget = JavaVersion.VERSION_17
2022
}
2123

2224
defaultConfig {
@@ -42,3 +44,8 @@ android {
4244
flutter {
4345
source = "../.."
4446
}
47+
48+
dependencies {
49+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
50+
}
51+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

test_integration/android/settings.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version "7.4.0" apply false
22-
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
21+
id "com.android.application" version "8.7.0" apply false
22+
id "org.jetbrains.kotlin.android" version "2.2.20" apply false
23+
id "com.google.gms.google-services" version "4.3.10" apply false
2324
}
2425

2526
include ":app"

0 commit comments

Comments
 (0)