From 2b900fe982e7709aef227584d0327b52b466fde4 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Thu, 26 Sep 2024 16:27:10 -0400 Subject: [PATCH] Update Android dependencies and AGP (#165) This updates kotlin, gson, AGP, and WorkManager to the latest versions. It also updates the README to include the correct ndk version for our AGP, as specified here: developer.android.com/build/releases/gradle-plugin#compatibility --- README.md | 2 +- android/app/build.gradle | 4 ++-- .../main/kotlin/net/defined/mobile_nebula/MainActivity.kt | 7 ++++++- .../kotlin/net/defined/mobile_nebula/NebulaVpnService.kt | 7 ++++++- android/settings.gradle | 4 ++-- lib/screens/AboutScreen.dart | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 01349af..f302413 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Run `flutter doctor` and fix everything it complains before proceeding - Copy `env.sh.example` and set it up for your machine - Ensure you have run `gomobile init` -- In Android Studio, make sure you have the current ndk installed by going to Tools -> SDK Manager, go to the SDK Tools tab, check the `Show package details` box, expand the NDK section and select `21.1.6352462` version. +- In Android Studio, make sure you have the current ndk installed by going to Tools -> SDK Manager, go to the SDK Tools tab, check the `Show package details` box, expand the NDK section and select `26.1.10909125` version. - Ensure you have downloaded an ndk via android studio, this is likely not the default one and you need to check the `Show package details` box to select the correct version. The correct version comes from the error when you try and compile - Make sure you have `gem` installed with `sudo gem install` diff --git a/android/app/build.gradle b/android/app/build.gradle index 5d924c4..ed72850 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -77,10 +77,10 @@ flutter { } dependencies { - def workVersion = "2.7.1" + def workVersion = "2.9.1" implementation "androidx.security:security-crypto:1.0.0" implementation "androidx.work:work-runtime-ktx:$workVersion" - implementation 'com.google.code.gson:gson:2.8.9' + implementation 'com.google.code.gson:gson:2.11.0' implementation "com.google.guava:guava:31.0.1-android" implementation project(':mobileNebula') diff --git a/android/app/src/main/kotlin/net/defined/mobile_nebula/MainActivity.kt b/android/app/src/main/kotlin/net/defined/mobile_nebula/MainActivity.kt index 65a496e..c030f62 100644 --- a/android/app/src/main/kotlin/net/defined/mobile_nebula/MainActivity.kt +++ b/android/app/src/main/kotlin/net/defined/mobile_nebula/MainActivity.kt @@ -98,7 +98,12 @@ class MainActivity: FlutterActivity() { apiClient = APIClient(context) - registerReceiver(refreshReceiver, IntentFilter(ACTION_REFRESH_SITES), RECEIVER_NOT_EXPORTED) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + registerReceiver(refreshReceiver, IntentFilter(ACTION_REFRESH_SITES), RECEIVER_NOT_EXPORTED) + } else { + @Suppress("UnspecifiedRegisterReceiverFlag") + registerReceiver(refreshReceiver, IntentFilter(ACTION_REFRESH_SITES)) + } enqueueDNUpdater() } diff --git a/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt b/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt index 6516321..0e2c8ef 100644 --- a/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt +++ b/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt @@ -213,7 +213,12 @@ class NebulaVpnService : VpnService() { } private fun registerReloadReceiver() { - registerReceiver(reloadReceiver, IntentFilter(ACTION_RELOAD), RECEIVER_NOT_EXPORTED) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + registerReceiver(reloadReceiver, IntentFilter(ACTION_RELOAD), RECEIVER_NOT_EXPORTED) + } else { + @Suppress("UnspecifiedRegisterReceiverFlag") + registerReceiver(reloadReceiver, IntentFilter(ACTION_RELOAD)) + } } private fun unregisterReloadReceiver() { diff --git a/android/settings.gradle b/android/settings.gradle index 1684940..3192560 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -18,8 +18,8 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version '8.5.2' apply false - id "org.jetbrains.kotlin.android" version "1.7.20" apply false + id "com.android.application" version '8.6.1' apply false + id "org.jetbrains.kotlin.android" version "2.0.20" apply false } include ':app', ':mobileNebula' \ No newline at end of file diff --git a/lib/screens/AboutScreen.dart b/lib/screens/AboutScreen.dart index b2c44b4..74055aa 100644 --- a/lib/screens/AboutScreen.dart +++ b/lib/screens/AboutScreen.dart @@ -73,7 +73,7 @@ class _AboutScreenState extends State { Padding( padding: EdgeInsets.only(top: 20), child: Text( - 'Copyright © 2022 Defined Networking, Inc', + 'Copyright © 2024 Defined Networking, Inc', textAlign: TextAlign.center, )), ]),