voice icon indicating copy to clipboard operation
voice copied to clipboard

expo SDK 52 does not build the app

Open umutsesen opened this issue 9 months ago • 8 comments

Steps:

npm i @react-native-voice/voice --save

app.json [ "@react-native-voice/voice", { "microphonePermission": "Allow our App to access the microphone", "speechRecognitionPermission": "Allow our App to securely recognize user speech" } ]

npx expo:run android

Android gradle plugin: 8.6.0 Gradle: 8.10.2

Task :app:processDebugMainManifest FAILED [com.android.support:animated-vector-drawable:28.0.0] C:\Users\Lenovo.gradle\caches\8.10.2\transforms\41bab62bd5df08c8278f986f64499a09\transformed\animated-vector-drawable-28.0.0\AndroidManifest.xml Warning: Namespace 'android.support.graphics.drawable' is used in multiple modules and/or libraries: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0. Please ensure that all modules and libraries have a unique namespace. For more information, See https://developer.android.com/studio/build/configure-app-module#set-namespace [androidx.versionedparcelable:versionedparcelable:1.1.1] C:\Users\Lenovo.gradle\caches\8.10.2\transforms\ac6f4b9f83cffa93ad7355b26826ebc2\transformed\versionedparcelable-1.1.1\AndroidManifest.xml Warning: Namespace 'androidx.versionedparcelable' is used in multiple modules and/or libraries: androidx.versionedparcelable:versionedparcelable:1.1.1, com.android.support:versionedparcelable:28.0.0. Please ensure that all modules and libraries have a unique namespace. For more information, See https://developer.android.com/studio/build/configure-app-module#set-namespace C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\android\app\src\debug\AndroidManifest.xml:28:18-86 Error: Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.13.1] AndroidManifest.xml:28:18-86 is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:6:5-162 to override.

See https://developer.android.com/r/studio-ui/build/manifest-merger for more information about the manifest merger.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processDebugMainManifest'.

Manifest merger failed with multiple errors, see logs

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.10.2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BU─░LD FAILED in 15s 283 actionable tasks: 7 executed, 276 up-to-date Error: C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1 Error: C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1 at ChildProcess.completionListener (C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\node_modules@expo\spawn-async\src\spawnAsync.ts:67:13) at Object.onceWrapper (node:events:632:26) at ChildProcess.emit (node:events:517:28) at ChildProcess.cp.emit (C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\node_modules\cross-spawn\lib\enoent.js:34:29) at maybeClose (node:internal/child_process:1098:16) at Process.ChildProcess._handle.onexit (node:internal/child_process:303:5) ... at spawnAsync (C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\node_modules@expo\spawn-async\src\spawnAsync.ts:28:21) at spawnGradleAsync (C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\node_modules@expo\cli\src\start\platforms\android\gradle.ts:134:28) at assembleAsync (C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\node_modules@expo\cli\src\start\platforms\android\gradle.ts:83:16) at runAndroidAsync (C:\Users\Lenovo\Desktop\Easy\easyNew\final\my-app\node_modules@expo\cli\src\run\android\runAndroidAsync.ts:48:24)

Tried clean install, some suggestions from GPT without result. If i use through expo without building app can be build but i get startSpeech of null even though permission is given both for expo and app itself. Error starting voice recognition: [TypeError: Cannot read property 'startSpeech' of null] #523

umutsesen avatar Mar 14 '25 15:03 umutsesen

Did you find any solution?

VaibhavBansa1 avatar Mar 16 '25 19:03 VaibhavBansa1

diff --git a/node_modules/@react-native-voice/voice/android/build.gradle b/node_modules/@react-native-voice/voice/android/build.gradle
index 8fce879..bda4ee1 100644
--- a/node_modules/@react-native-voice/voice/android/build.gradle
+++ b/node_modules/@react-native-voice/voice/android/build.gradle
@@ -62,6 +62,5 @@ def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.
 dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     testImplementation 'junit:junit:4.12'
-    implementation "com.android.support:appcompat-v7:${supportVersion}"
     implementation 'com.facebook.react:react-native:+'
 }
diff --git a/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java b/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
index f22833e..1ab1fea 100644
--- a/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
+++ b/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
@@ -322,10 +322,17 @@ public class VoiceModule extends ReactContextBaseJavaModule implements Recogniti
     WritableArray arr = Arguments.createArray();
 
     ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
-    for (String result : matches) {
-      arr.pushString(result);
+    if (matches != null) {
+      for (String result : matches) {
+        arr.pushString(result);
+      }
+
     }
 
+       if (results == null || results.isEmpty()) {
+         return;
+       }
+
     WritableMap event = Arguments.createMap();
     event.putArray("value", arr);
     sendEvent("onSpeechPartialResults", event);
@@ -345,10 +352,18 @@ public class VoiceModule extends ReactContextBaseJavaModule implements Recogniti
     WritableArray arr = Arguments.createArray();
 
     ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
-    for (String result : matches) {
-      arr.pushString(result);
+    if (matches != null) {
+      for (String result : matches) {
+        arr.pushString(result);
+      }
+
     }
 
+    if (results == null || results.isEmpty()) {
+      return;
+    }
+
+
     WritableMap event = Arguments.createMap();
     event.putArray("value", arr);
     sendEvent("onSpeechResults", event);
diff --git a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
index fd9dad8..4fae8e3 100644
--- a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
+++ b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
@@ -224,6 +224,7 @@ - (void) setupAndStartRecognizing:(NSString*)localeStr {
     @try {
         [mixer installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
             //Volume Level Metering
+            [buffer setFrameLength:buffer.frameCapacity];
             UInt32 inNumberFrames = buffer.frameLength;
             float LEVEL_LOWPASS_TRIG = 0.5;
             if(buffer.format.channelCount>0)

use this patch, that works for me

houabdu avatar Mar 27 '25 12:03 houabdu

how to use this patch ?

satya1395 avatar Apr 23 '25 05:04 satya1395

diff --git a/node_modules/@react-native-voice/voice/android/build.gradle b/node_modules/@react-native-voice/voice/android/build.gradle
index 8fce879..bda4ee1 100644
--- a/node_modules/@react-native-voice/voice/android/build.gradle
+++ b/node_modules/@react-native-voice/voice/android/build.gradle
@@ -62,6 +62,5 @@ def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.
 dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     testImplementation 'junit:junit:4.12'
-    implementation "com.android.support:appcompat-v7:${supportVersion}"
     implementation 'com.facebook.react:react-native:+'
 }
diff --git a/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java b/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
index f22833e..1ab1fea 100644
--- a/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
+++ b/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
@@ -322,10 +322,17 @@ public class VoiceModule extends ReactContextBaseJavaModule implements Recogniti
     WritableArray arr = Arguments.createArray();
 
     ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
-    for (String result : matches) {
-      arr.pushString(result);
+    if (matches != null) {
+      for (String result : matches) {
+        arr.pushString(result);
+      }
+
     }
 
+       if (results == null || results.isEmpty()) {
+         return;
+       }
+
     WritableMap event = Arguments.createMap();
     event.putArray("value", arr);
     sendEvent("onSpeechPartialResults", event);
@@ -345,10 +352,18 @@ public class VoiceModule extends ReactContextBaseJavaModule implements Recogniti
     WritableArray arr = Arguments.createArray();
 
     ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
-    for (String result : matches) {
-      arr.pushString(result);
+    if (matches != null) {
+      for (String result : matches) {
+        arr.pushString(result);
+      }
+
     }
 
+    if (results == null || results.isEmpty()) {
+      return;
+    }
+
+
     WritableMap event = Arguments.createMap();
     event.putArray("value", arr);
     sendEvent("onSpeechResults", event);
diff --git a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
index fd9dad8..4fae8e3 100644
--- a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
+++ b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
@@ -224,6 +224,7 @@ - (void) setupAndStartRecognizing:(NSString*)localeStr {
     @try {
         [mixer installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
             //Volume Level Metering
+            [buffer setFrameLength:buffer.frameCapacity];
             UInt32 inNumberFrames = buffer.frameLength;
             float LEVEL_LOWPASS_TRIG = 0.5;
             if(buffer.format.channelCount>0)

use this patch, that works for me

It worked for me 🎉

davidch-lqc avatar May 02 '25 07:05 davidch-lqc

how to use this patch ?

  1. You need to install & configure patch-package
  2. Create patches folder on root level
  3. Add this file inside patches folder: @react-native-voice+voice+3.2.4.patch (3.2.4 is a version of the voice library you are using - check in package.json)
  4. Put @houabdu's patch in that file & run npx patch-package

davidch-lqc avatar May 02 '25 07:05 davidch-lqc

how to use this patch ?

  1. You need to install & configure patch-package
  2. Create patches folder on root level
  3. Add this file inside patches folder: @react-native-voice+voice+3.2.4.patch (3.2.4 is a version of the voice library you are using - check in package.json)
  4. Put @houabdu's patch in that file & run npx patch-package

This does not solve the production building over EAS. When will this be merged into release?

Hiti3 avatar May 06 '25 11:05 Hiti3

How to fix this issue I'm also facing this issue

shoaibarif244 avatar May 12 '25 10:05 shoaibarif244

The solution https://github.com/react-native-voice/voice/issues/530

jsnavarroc avatar Jun 11 '25 23:06 jsnavarroc