Skip to content

Commit 46d07f0

Browse files
authored
Merge pull request #579 from ably/ECO-5566/gradle-upgrade
[ECO-5566] chore: update Android Gradle build to support the newer Flutter SDK
2 parents 720d5cb + 1566840 commit 46d07f0

File tree

8 files changed

+37
-32
lines changed

8 files changed

+37
-32
lines changed

.github/workflows/flutter_integration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
5454
- uses: subosito/flutter-action@v2
5555
with:
56-
flutter-version: '3.24'
56+
flutter-version: '3.29'
5757
cache: true
5858

5959
- name: 'Run Flutter Driver tests'
@@ -65,4 +65,4 @@ jobs:
6565
disable-animations: true
6666
script: |
6767
flutter pub get
68-
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: 16 additions & 19 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

@@ -26,36 +28,25 @@ dependencies {
2628
implementation 'io.ably:ably-android:1.2.40'
2729

2830
// https://firebase.google.com/docs/cloud-messaging/android/client
29-
implementation 'com.google.firebase:firebase-messaging:23.0.4'
30-
31-
// https://github.com/google/desugar_jdk_libs
32-
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
31+
implementation 'com.google.firebase:firebase-messaging:23.0.6'
3332
}
3433

3534
android {
36-
compileSdkVersion 34
35+
// older version of flutter sdk doesn't provide `compileSdkVersion` defaults to 34
36+
compileSdkVersion flutter.compileSdkVersion ?: 34
3737

3838
// Conditional for compatibility with AGP <4.2.
3939
if (project.android.hasProperty("namespace")) {
4040
namespace 'io.ably.flutter.plugin'
4141
}
4242

43-
// Require Java language level 8 so we can use Method References (used with Lambdas)
4443
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
44+
sourceCompatibility = JavaVersion.VERSION_17
45+
targetCompatibility = JavaVersion.VERSION_17
5046
}
5147

5248
defaultConfig {
5349
minSdkVersion 19
54-
55-
// Required when setting minSdkVersion to 20 or lower so we can use
56-
// the Java 8 language APIs as mentioned here:
57-
// https://developer.android.com/studio/write/java8-support#library-desugaring
58-
multiDexEnabled true
5950
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
6051
}
6152
lintOptions {
@@ -66,4 +57,10 @@ android {
6657
}
6758
}
6859

60+
gradle.projectsEvaluated {
61+
tasks.withType(JavaCompile) {
62+
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
63+
}
64+
}
65+
6966
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)