react-native-voice / voice

:microphone: React Native Voice Recognition library for iOS and Android (Online and Offline Support)
MIT License
1.84k stars 495 forks source link

:react-native-voice_voice:packageDebugResources' (type 'MergeResources') #489

Open socialmad opened 8 months ago

socialmad commented 8 months ago

After updating our project with a new React Native engine and upgrading Gradle to version 8.6, we encountered an issue. We have tried various solutions, but none have worked so far.

VictorDev200 commented 8 months ago

Same to me on Gradle 8.0.1:

VictorDev200 commented 7 months ago

@socialmad I think I have a solution, do npm install react-native-voice and run the app, avoid doing the manual linking steps, it breaks the app. so just npm install should work

adamgusky commented 5 months ago

Any other solution? @VictorDev200's did not work for me unfortunately

kovikarthik commented 3 months ago

Remove "implementation project(':@react-native-voice_voice')" from android/app/build.gradle file

And also remove following declarations from android/settings.gradle include ':@react-native-voice_voice' project(':@react-native-voice_voice').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-voice/voice/android')

declarations i used in android/app/src/main/androidmanifest.xml file "uses-permission android:name="android.permission.RECORD_AUDIO"

and try now with cd android ./gradlew clean or gradlew clean npm run android

jespirit commented 3 months ago

Putting this here so that people who run into the same issue as I did here. These are my build environment:

$ npm list -g
C:\Users\jeff_\AppData\Roaming\npm
├── react-native-cli@2.0.1
└── react-native@0.75.1

  "dependencies": {
    "@react-native-voice/voice": "^3.2.4",
    "react": "18.3.1",
    "react-native": "0.75.1"
  },

Gradle version is 8.8
Android SDK Platform 35

I followed @kovikarthik instructions. So basically I removed the manual linking. It appears that React native handles it automatically. However, I was getting another error:

> Task :app:processDebugMainManifest
[com.android.support:animated-vector-drawable:28.0.0] C:\Users\jeff_\.gradle\caches\8.8\transforms\af367b6b2b00bd2373f3a4bbc3cf0def\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\jeff_\.gradle\caches\8.8\transforms\41ea63f3dabe1a140c4792fedd6e315d\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

> Task :app:checkDebugDuplicateClasses FAILED

To fix this, I removed appcompat-v7 from build.gradle because react native was using AndroidX (androidx.appcompat) while react-native-voice module was still using the deprecated Android Support Library (appcompat-v7) which was causing a conflict where the same namespace was defined in two places.

<react-project>\node_modules\@react-native-voice\voice\android\build.gradle

implementation "com.android.support:appcompat-v7:${supportVersion}"

kxhelilaj commented 3 months ago

i had the same issue and the @jespirit solution worked. One question @jespirit since we are modifying the node_modules, you forked the repository and use it like that ?

jespirit commented 3 months ago

@kxhelilaj I learned you can use patch-package to create a patch that can be added to source control which can be applied during post-install stage https://stackoverflow.com/questions/72820625/what-is-the-proper-way-to-patch-a-node-modules-module Note: The patch-package command picked up some other changes so I just removed those and left the relevant part.

anhtukhtn commented 1 month ago

@jespirit remove maual linking worked for me, thank you very much.