Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native-html-to-pdf collides react-native #124

Closed
danielsouzapinna opened this issue May 7, 2019 · 11 comments
Closed

react-native-html-to-pdf collides react-native #124

danielsouzapinna opened this issue May 7, 2019 · 11 comments
Labels

Comments

@danielsouzapinna
Copy link

Hi all,

When I installed the react-native-html-to-pdf package, I received the error below:

Duplicate module name: Sample
  Paths: C: \ projects \ signature-electronics \ node_modules \ react-native-html-to-pdf \ example \ node_modules \ react-native \ Libraries \ Sample.config.json collides with C: \ projects \ signature-electronics \ node_modules \ react-native \ Libraries \ Sample \ package.json

Can you rename the dir "react-native-html-to-pdf\example\node_modules\react-native\ Libraries\Sample" to another name to avoid this error?

Thanks

@MarcosSarges
Copy link
Contributor

MarcosSarges commented May 7, 2019

I have the same problem.
I deleted the sample folder but it generated another error.



> Task :react-native-html-to-pdf:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-html-to-pdf:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:7: error: resource android:attr/colorError not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:11: error: resource android:attr/colorError not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values/values.xml:2711: error: resource android:attr/fontStyle not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values/values.xml:2712: error: resource android:attr/font not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values/values.xml:2713: error: resource android:attr/fontWeight not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values/values.xml:2714: error: resource android:attr/fontVariationSettings not found.
  /home/mp/tcc/epbl/node_modules/react-native-html-to-pdf/android/build/intermediates/res/merged/release/values/values.xml:2715: error: resource android:attr/ttcIndex not found.
  error: failed linking references.


* 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

@MarcosSarges
Copy link
Contributor

MarcosSarges commented May 8, 2019

1- first delete folder "Example" for fix problem of conflict of "package.json".
2 - Within the build.gradle file of r-n-html-to-pdf, I reconfigured the dependencies and did the build successfully


buildscript {
     ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


apply plugin: 'com.android.library'

android {
     compileSdkVersion rootProject.ext.compileSdkVersion
     compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    compileSdkVersion 26
  compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
}

repositories {
    mavenCentral()
}


dependencies {
    implementation 'com.tom_roush:pdfbox-android:1.8.10.0'
    implementation 'com.facebook.react:react-native:+'
}

@krstffr
Copy link

krstffr commented May 8, 2019

I have the same issue. This seem to be a common issue across multiple packages, and some solutions (which don't work for me) have been proposed here: facebook/react-native#21242

@krstffr
Copy link

krstffr commented May 8, 2019

OK, actually (when I tried it once again!) it works.
This is my metro.config.js-file which fixed it (the resolver/blacklistRE field is where the magic happens):

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

const blacklist = require("metro-config/src/defaults/blacklist");

module.exports = {
  resolver: {
    blacklistRE: blacklist([/node_modules\/.*\/node_modules\/react-native\/.*/])
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false
      }
    })
  }
};

@SimonErm
Copy link
Contributor

#110

@williamhqs
Copy link

williamhqs commented May 15, 2019

I got the same error and a very familiar error react-animated

Loading dependency graph...(node:13027) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
  Duplicate module name: react-animated
  Paths: /A/RNCreatePDF/node_modules/react-native-html-to-pdf/example/node_modules/react-native/Libraries/Animated/release/package.json collides with /A/RNCreatePDF/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by `hasteImpl` returning the same name for different files.
    at setModule (/A/RNCreatePDF/node_modules/jest-haste-map/build/index.js:569:17)
    at workerReply (/A/RNCreatePDF/node_modules/jest-haste-map/build/index.js:641:9)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:13027) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

And I finally figured out the problem, the Sample module conflict with react native.

The solution is:
add this line into package.json
"postInstall":"rm -rf node_modules/react-native-html-to-pdf/example"
then run
npm postInstall
well, solved. ( I think rm -rf node_modules/react-native-html-to-pdf/example" should be the key)

@SpyderScrypt
Copy link

None of the above works for me.... is there any easy solution?

@GreenRidingHood
Copy link

nothing worked with me either,
i am following #98
issue#98 too, but it did not help either.

@SpyderScrypt did you find any solution?

@GreenRidingHood
Copy link

that solution helped me, now i get apk successfully

facebook/react-native#19239 (comment)

@stale
Copy link

stale bot commented Dec 28, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 28, 2020
@stale stale bot closed this as completed Jan 4, 2021
@coucoseth
Copy link

My solution :

Delete node modules folder and run "npm i" in the terminal to reinstall node modules.
This solved this same issue i was facing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants