ak1394 / react-native-tts

React Native Text-To-Speech library for Android and iOS
601 stars 154 forks source link

How to remove Warn new NativeEventEmitter ? #237

Open praptoherlambang opened 1 year ago

praptoherlambang commented 1 year ago

this is so annoying.

new NativeEventEmitter() was called with a non-null argument without the required addListener method. new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

how fix this issues guys..

celciusjj commented 1 year ago

Same issue

vito-mish commented 1 year ago

node_modules/react-native-tts/android/src/main/java/net/no_mad/tts/TextToSpeechModule.java

Just add this.

    @ReactMethod
    public void addListener(String eventName) {
        // Keep: Required for RN built in Event Emitter Calls.
    }

    @ReactMethod
    public void removeListeners(double count) {
        // Keep: Required for RN built in Event Emitter Calls.
    }

Ref this PR: https://github.com/invertase/react-native-firebase/pull/5616/files#diff-c887076b0c80d540aed1bfbb472cc8f20516634e8e72d53014c65d690bba4fb1

1NoobDev commented 1 year ago

I tried to 'just' add the provided code snippets inside node_modules/react-native-tts/android/src/main/java/net/no_mad/tts/TextToSpeechModule.java

but when running npx react-native run-android I get the following error:

BUILD FAILED in 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\Development\MobileApps\AwesomeProject\node_modules\react-native-tts\android\src\main\java\net\no_mad\tts\TextToSpeechModule.java:531: error: class, interface, or enum expected
    public void addListener(String eventName) {
           ^
D:\Development\MobileApps\AwesomeProject\node_modules\react-native-tts\android\src\main\java\net\no_mad\tts\TextToSpeechModule.java:536: error: class, interface, or enum expected
    public void removeListeners(double count) {
           ^
2 errors

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-tts:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Could you clarify a bit more? As the PR is a whole other file than the file you mention?!

syednomishah commented 1 year ago

I can't find this java file inside android folder, is there another fix?

haiffy420 commented 3 months ago

I can't find this java file inside android folder, is there another fix?

it's inside node_modules folder. if you're using VS Code,

CTRL + P > Paste node_modules/react-native-tts/android/src/main/java/net/no_mad/tts/TextToSpeechModule.java > Enter