From 2cb1225d1ff9cbc60c4c0f710779ad6a117315a4 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sat, 24 Oct 2026 01:12:00 -0400 Subject: [PATCH] Fix Android Gradle and on_device_tts Kotlin build warnings --- android/app/build.gradle | 35 +++++++++---------- android/gradle.properties | 2 +- .../on_device_tts/android/build.gradle.kts | 6 ++-- .../muxable/ondevicetts/SystemTtsPlugin.kt | 7 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index b913ea451..1c835e888 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -34,43 +34,41 @@ if (flutterVersionName == null) { } android { - namespace 'com.rtirl.chat' - compileSdkVersion flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + namespace = 'com.rtirl.chat' + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion sourceSets { main.java.srcDirs += 'src/main/kotlin' } compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } defaultConfig { - applicationId "com.rtirl.chat" - minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion - versionCode vcode - versionName flutterVersionName - multiDexEnabled true + applicationId = "com.rtirl.chat" + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = vcode + versionName = flutterVersionName } signingConfigs { release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] + keyAlias = keystoreProperties['keyAlias'] + keyPassword = keystoreProperties['keyPassword'] + storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storePassword = keystoreProperties['storePassword'] } } buildTypes { release { - signingConfig signingConfigs.release + signingConfig = signingConfigs.release } } - namespace 'com.rtirl.chat' } kotlin { @@ -80,12 +78,11 @@ kotlin { } flutter { - source '../..' + source = '../..' } dependencies { implementation "androidx.media:media:1.7.1" - implementation 'androidx.multidex:multidex:2.0.1' implementation 'com.google.android.play:app-update:2.1.0' implementation 'com.google.android.play:feature-delivery:2.1.0' } diff --git a/android/gradle.properties b/android/gradle.properties index 1a193b796..734c05c96 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true -android.enableJetifier=true +org.gradle.caching=true # This builtInKotlin flag was added automatically by Flutter migrator android.builtInKotlin=false # This newDsl flag was added automatically by Flutter migrator diff --git a/packages/on_device_tts/android/build.gradle.kts b/packages/on_device_tts/android/build.gradle.kts index becd002ea..52603bad5 100644 --- a/packages/on_device_tts/android/build.gradle.kts +++ b/packages/on_device_tts/android/build.gradle.kts @@ -29,7 +29,7 @@ plugins { // parity and emulator tests when you do. val onnxRuntimeVersion = "1.31.0" -android { +configure { namespace = "com.muxable.ondevicetts" compileSdk = 36 @@ -41,10 +41,10 @@ android { sourceSets { getByName("main") { - java.srcDirs("src/main/kotlin") + java.directories.add("src/main/kotlin") } getByName("test") { - java.srcDirs("src/test/kotlin") + java.directories.add("src/test/kotlin") } } diff --git a/packages/on_device_tts/android/src/main/kotlin/com/muxable/ondevicetts/SystemTtsPlugin.kt b/packages/on_device_tts/android/src/main/kotlin/com/muxable/ondevicetts/SystemTtsPlugin.kt index 42d804c36..f21159ebd 100644 --- a/packages/on_device_tts/android/src/main/kotlin/com/muxable/ondevicetts/SystemTtsPlugin.kt +++ b/packages/on_device_tts/android/src/main/kotlin/com/muxable/ondevicetts/SystemTtsPlugin.kt @@ -721,7 +721,7 @@ class SystemTtsPlugin : MethodCallHandler, FlutterPlugin { val file = File(fileName) fullPath = file.path - tts!!.synthesizeToFile(text, bundle!!, file!!, SYNTHESIZE_TO_FILE_PREFIX + uuid) + tts!!.synthesizeToFile(text, bundle!!, file, SYNTHESIZE_TO_FILE_PREFIX + uuid) } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { val resolver = this.context?.contentResolver val contentValues = ContentValues().apply { @@ -739,7 +739,7 @@ class SystemTtsPlugin : MethodCallHandler, FlutterPlugin { val file = File(musicDir, fileName) fullPath = file.path - tts!!.synthesizeToFile(text, bundle!!, file!!, SYNTHESIZE_TO_FILE_PREFIX + uuid) + tts!!.synthesizeToFile(text, bundle!!, file, SYNTHESIZE_TO_FILE_PREFIX + uuid) } if (result == TextToSpeech.SUCCESS) { @@ -804,6 +804,8 @@ class SystemTtsPlugin : MethodCallHandler, FlutterPlugin { .build() audioManager?.requestAudioFocus(audioFocusRequest!!) } else { + // minSdk is 24; AudioFocusRequest needs API 26. + @Suppress("DEPRECATION") audioManager?.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK) } } @@ -812,6 +814,7 @@ class SystemTtsPlugin : MethodCallHandler, FlutterPlugin { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { audioFocusRequest?.let { audioManager?.abandonAudioFocusRequest(it) } } else { + @Suppress("DEPRECATION") audioManager?.abandonAudioFocus(null) } }