Skip to content

Android Build Fails: Resource Merger Cannot Find Layout File in react-native-moyasar-sdk with pnpmΒ #499

@ahmedsomaa

Description

@ahmedsomaa

Android Build Fails: Resource Merger Cannot Find Layout File in react-native-moyasar-sdk with pnpm

Description

Android build fails when using react-native-moyasar-sdk with pnpm package manager. The Gradle resource merger cannot locate the layout file fragment_samsung_pay.xml due to symlink resolution issues with pnpm's node_modules structure.

Error Message

ERROR: /home/som3aware/Projects/Hivo/hivo-apps/apps/mobile/node_modules/react-native-moyasar-sdk/android/src/main/res/layout/fragment_samsung_pay.xml: Resource and asset merger: Layout file /home/som3aware/Projects/Hivo/hivo-apps/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_08710d1b04148675f6ec39c39e6303f1/node_modules/react-native-moyasar-sdk/android/src/main/res/layout/fragment_samsung_pay.xml is not located in [/home/som3aware/Projects/Hivo/hivo-apps/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_08710d1b04148675f6ec39c39e6303f1/node_modules/react-native-moyasar-sdk/android/src/debug/res, /home/som3aware/Projects/Hivo/hivo-apps/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_08710d1b04148675f6ec39c39e6303f1/node_modules/react-native-moyasar-sdk/android/src/main/res]

java.lang.IllegalStateException: Layout file .../fragment_samsung_pay.xml is not located in [...]

Task: :react-native-moyasar-sdk:packageDebugResources

Steps to Reproduce

  1. Use pnpm as package manager
  2. Install react-native-moyasar-sdk@^0.10.0
  3. Run Android build: cd android && ./gradlew app:assembleDebug
  4. Build fails during resource merging phase

Expected Behavior

The Android build should complete successfully, with Gradle correctly resolving the layout file through pnpm's symlink structure.

Actual Behavior

Build fails with resource merger error, unable to locate fragment_samsung_pay.xml despite the file existing in the pnpm store.

Environment

  • Project Template: react-native obytes template
  • Package Manager: pnpm
  • react-native-moyasar-sdk: ^0.10.0 (resolves to 0.10.1)
  • React Native: 0.79.6
  • Gradle: 8.13
  • Android Gradle Plugin: (from React Native 0.79.6)
  • OS: Linux (Fedora 43)
  • Node: (version from environment)

File Location Details

The file exists and is accessible:

The symlink resolves correctly via readlink -f, but Gradle's resource merger cannot follow it.

Workarounds Attempted

  1. βœ… Cleaned Gradle caches (./gradlew clean)
  2. βœ… Removed .gradle and build directories
  3. ❌ Issue persists

Possible Solutions

  1. Configure Gradle to follow symlinks - May need to add configuration to handle pnpm's symlink structure
  2. Update react-native-moyasar-sdk - Check if newer versions have fixed this issue
  3. Modify Android build configuration - Add explicit resource path resolution for pnpm
  4. Use npm/yarn instead of pnpm - Not ideal, but would work around the issue

Additional Context

This project is based on the react-native obytes template, which may have specific Android build configurations that interact with this issue.

This appears to be a known issue with pnpm and Android Gradle builds, where the resource merger doesn't properly resolve symlinked resources. The issue is specific to pnpm's node_modules structure, which uses symlinks to a centralized store.

Note: There's currently a workaround attempt in react-native.config.js that excludes fragment_samsung_pay.xml, but this doesn't resolve the issue:

'react-native-moyasar-sdk': {
  platforms: {
    android: {
      packagingOptions: {
        exclude: ['**/fragment_samsung_pay.xml'],
      },
    },
  },
},

This exclusion doesn't prevent Gradle from trying to process the file during the resource merging phase.

Related Issues

  • Similar issues may exist with other React Native libraries when using pnpm
  • This could be related to Android Gradle Plugin's resource merging behavior with symlinks

Build Log Snippet

Task :react-native-moyasar-sdk:packageDebugResources FAILED
ERROR: .../fragment_samsung_pay.xml: Resource and asset merger: Layout file .../fragment_samsung_pay.xml is not located in [...]
    java.lang.IllegalStateException: Layout file .../fragment_samsung_pay.xml is not located in [...]
        at com.android.build.gradle.tasks.MergeResources$maybeCreateLayoutProcessor$1.processSingleFile(MergeResources.kt:617)

Note: This issue should be reported to the react-native-moyasar-sdk repository if it exists, or may need to be addressed in the Android build configuration of the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions