From 64f0179cefe1ea49ef4c14b0aa7d1f80741b4aad Mon Sep 17 00:00:00 2001 From: Jelle Breuer Date: Tue, 8 Sep 2026 08:58:02 +0200 Subject: [PATCH] fix(android): use reactApplicationContext.currentActivity for RN 0.87 ReactContextBaseJavaModule was converted to Kotlin, so getCurrentActivity() is now a fun rather than a Java getter and Kotlin synthetic property access no longer resolves, failing the build with: e: RNSpeechModule.kt:733:22 Function invocation 'getCurrentActivity()' expected. It has also been deprecated since 0.80.0 in favour of reactApplicationContext.currentActivity, which is what its ReplaceWith names. Both accessors it goes through are still Java getters, so this compiles on old and new React Native alike and drops a deprecation warning. Fixes #15 --- android/src/main/java/com/speech/RNSpeechModule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/speech/RNSpeechModule.kt b/android/src/main/java/com/speech/RNSpeechModule.kt index 0ae28af..081cea8 100644 --- a/android/src/main/java/com/speech/RNSpeechModule.kt +++ b/android/src/main/java/com/speech/RNSpeechModule.kt @@ -730,7 +730,7 @@ class RNSpeechModule(reactContext: ReactApplicationContext) : override fun openVoiceDataInstaller(promise: Promise) { try { - val activity = currentActivity ?: throw Exception("The current activity is not available to launch the installer.") + val activity = reactApplicationContext.currentActivity ?: throw Exception("The current activity is not available to launch the installer.") val intent = Intent(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA) if (intent.resolveActivity(activity.packageManager) != null) { activity.startActivity(intent)