voice icon indicating copy to clipboard operation
voice copied to clipboard

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

Open socialmad opened this issue 1 year ago • 11 comments

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.

  • What went wrong: A problem was found with the configuration of task ':react-native-voice_voice:packageDebugResources' (type 'MergeResources').
    • Gradle detected a problem with the following location: 'C:\ABSYZ\myhub-app\node_modules@react-native-voice\voice\android\build\generated\res\resValues\debug'.

      Reason: Task ':react-native-voice_voice:packageDebugResources' uses this output of task ':@react-native-voice_voice:generateDebugResValues' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

      Possible solutions:

      1. Declare task ':@react-native-voice_voice:generateDebugResValues' as an input of ':react-native-voice_voice:packageDebugResources'.
      2. Declare an explicit dependency on ':@react-native-voice_voice:generateDebugResValues' from ':react-native-voice_voice:packageDebugResources' using Task#dependsOn.
      3. Declare an explicit dependency on ':@react-native-voice_voice:generateDebugResValues' from ':react-native-voice_voice:packageDebugResources' using Task#mustRunAfter.

socialmad avatar Mar 18 '24 09:03 socialmad

Same to me on Gradle 8.0.1:

  • What went wrong: Some problems were found with the configuration of task ':react-native-voice_voice:packageDebugResources' (type 'MergeResources').
    • Gradle detected a problem with the following location: 'node_modules@react-native-voice\voice\android\build\generated\res\rs\debug'.

      Reason: Task ':react-native-voice_voice:packageDebugResources' uses this output of task ':@react-native-voice_voice:compileDebugRenderscript' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

      Possible solutions:

      1. Declare task ':@react-native-voice_voice:compileDebugRenderscript' as an input of ':react-native-voice_voice:packageDebugResources'.
      2. Declare an explicit dependency on ':@react-native-voice_voice:compileDebugRenderscript' from ':react-native-voice_voice:packageDebugResources' using Task#dependsOn.
      3. Declare an explicit dependency on ':@react-native-voice_voice:compileDebugRenderscript' from ':react-native-voice_voice:packageDebugResources' using Task#mustRunAfter.

      Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

    • Gradle detected a problem with the following location: 'node_modules@react-native-voice\voice\android\build\generated\res\resValues\debug'.

      Reason: Task ':react-native-voice_voice:packageDebugResources' uses this output of task ':@react-native-voice_voice:generateDebugResValues' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

      Possible solutions:

      1. Declare task ':@react-native-voice_voice:generateDebugResValues' as an input of ':react-native-voice_voice:packageDebugResources'.
      2. Declare an explicit dependency on ':@react-native-voice_voice:generateDebugResValues' from ':react-native-voice_voice:packageDebugResources' using Task#dependsOn.
      3. Declare an explicit dependency on ':@react-native-voice_voice:generateDebugResValues' from ':react-native-voice_voice:packageDebugResources' using Task#mustRunAfter.

      Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

VictorDev200 avatar Mar 22 '24 14:03 VictorDev200

@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

VictorDev200 avatar Apr 12 '24 22:04 VictorDev200

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

adamgusky avatar Jun 27 '24 23:06 adamgusky

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

kovikarthik avatar Jul 30 '24 06:07 kovikarthik

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
├── [email protected]
└── [email protected]

  "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}"

jespirit avatar Aug 20 '24 04:08 jespirit

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 ?

kxhelilaj avatar Aug 20 '24 10:08 kxhelilaj

@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.

jespirit avatar Aug 25 '24 15:08 jespirit

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

anhtukhtn avatar Oct 16 '24 04:10 anhtukhtn

Just add/modify android.enableJetifier=true in your settings.gradle and make sure to clear the cache before building your app.

Hope it helps...

Ayush-Bharadva avatar Dec 26 '24 08:12 Ayush-Bharadva

@Ayush-Bharadva Thanks, it really worked

Lovepreet-Quadrish avatar Feb 14 '25 11:02 Lovepreet-Quadrish

Hello. I had same issue early this year, hacked my way around twice through lot of trials, manuals, stackoverflow, AI, etc. The two ways were:

  1. Remove manual linking from android/app/build.gradle :

    • remove this line : implementation project(':@react-native-voice_voice')
  2. use afterevaluate - took time to ge it right, ill share it when i find that exact one. but it was quirky so first one was best

But now late in the year, im having to update the app libraries, so i bump RN version from 0.76 to 0.81. Somehow, the new autolinking in 0.81 wont force gradle to build the native module of rn voice, hence app builds but JS side sees empty Voice module, hence wont work. I realized autolinking in older RN wasnt so strict about dependency graph, this one is.

I cant seem to find the solution. even afterevaluate hacks dont seem to work. Anyone with solution?

leomuguchia avatar Nov 29 '25 22:11 leomuguchia