Skip to content

Commit 11911bd

Browse files
committed
(chore): support flutter 3.29
1 parent 4ff716b commit 11911bd

File tree

8 files changed

+106
-98
lines changed

8 files changed

+106
-98
lines changed

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ group 'io.agora.agora_rtm'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.7.0'
5+
ext.kotlin_version = '1.9.20'
66
repositories {
77
google()
88
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:7.1.2'
12+
classpath 'com.android.tools.build:gradle:8.1.4'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}
@@ -29,7 +29,7 @@ android {
2929
if (project.android.hasProperty("namespace")) {
3030
namespace 'io.agora.agora_rtm'
3131
}
32-
compileSdkVersion 31
32+
compileSdk 35
3333

3434
compileOptions {
3535
sourceCompatibility JavaVersion.VERSION_1_8

android/src/main/kotlin/io/agora/agorartm/AgoraRtmPlugin.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ import io.flutter.plugin.common.MethodCall
1919
import io.flutter.plugin.common.MethodChannel
2020
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
2121
import io.flutter.plugin.common.MethodChannel.Result
22-
import io.flutter.plugin.common.PluginRegistry.Registrar
2322

2423
class AgoraRtmPlugin : FlutterPlugin, MethodCallHandler {
25-
private var registrar: Registrar? = null
2624
private var binding: FlutterPlugin.FlutterPluginBinding? = null
2725
private lateinit var applicationContext: Context
2826
private lateinit var methodChannel: MethodChannel
@@ -31,16 +29,6 @@ class AgoraRtmPlugin : FlutterPlugin, MethodCallHandler {
3129
private var nextClientIndex: Long = 0
3230
private var clients = HashMap<Long, RTMClient>()
3331

34-
companion object {
35-
@JvmStatic
36-
fun registerWith(registrar: Registrar) {
37-
AgoraRtmPlugin().apply {
38-
this.registrar = registrar
39-
initPlugin(registrar.context(), registrar.messenger())
40-
}
41-
}
42-
}
43-
4432
private fun initPlugin(
4533
context: Context, binaryMessenger: BinaryMessenger
4634
) {
@@ -183,7 +171,7 @@ class AgoraRtmPlugin : FlutterPlugin, MethodCallHandler {
183171
applicationContext,
184172
appId,
185173
nextClientIndex,
186-
registrar?.messenger() ?: binding!!.binaryMessenger,
174+
binding!!.binaryMessenger,
187175
handler
188176
)
189177
object : Callback<Long>(result, handler) {}.onSuccess(nextClientIndex)
@@ -256,7 +244,7 @@ class AgoraRtmPlugin : FlutterPlugin, MethodCallHandler {
256244
val agoraRtmChannel = RTMChannel(
257245
clientIndex,
258246
channelId,
259-
registrar?.messenger() ?: binding!!.binaryMessenger,
247+
binding!!.binaryMessenger,
260248
handler
261249
)
262250
client.createChannel(channelId, agoraRtmChannel)?.let {

example/android/app/build.gradle

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
612
}
713
}
814

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
1415
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1516
if (flutterVersionCode == null) {
1617
flutterVersionCode = '1'
@@ -21,11 +22,10 @@ if (flutterVersionName == null) {
2122
flutterVersionName = '1.0'
2223
}
2324

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
2825
android {
26+
if (project.android.hasProperty("namespace")) {
27+
namespace 'io.agora.agora_rtm_example'
28+
}
2929
compileSdkVersion flutter.compileSdkVersion
3030

3131
compileOptions {
@@ -64,7 +64,3 @@ android {
6464
flutter {
6565
source '../..'
6666
}
67-
68-
dependencies {
69-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
70-
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="io.agora.agora_rtm_example">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<application
43
android:label="agora_rtm_example"
54
android:name="${applicationName}"

example/android/build.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
buildscript {
2-
ext.kotlin_version = '1.7.0'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.1.2'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()

example/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-7.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip

example/android/settings.gradle

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

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"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.1.4" apply false
22+
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
23+
}
24+
25+
include ":app"

0 commit comments

Comments
 (0)