wonday / react-native-pdf

A <Pdf /> component for react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

installation

johntom opened this issue · comments

Hi.
While I have no problems with IOS with the exact setup I've tried to install on a few windows 10 comptuters with RN 0.41 and get the following error
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\React\nsp\NSPV6\NativeStarterPro-v6.0.0>npm install react-native-pdf --save
react-native-pdf@1.2.4 node_modules\react-native-pdf
├── crypto-js@3.1.9-1
└── react-native-fetch-blob@0.10.6 (glob@7.1.2)

C:\React\nsp\NSPV6\NativeStarterPro-v6.0.0>react-native link react-native-pdf
rnpm-install info Linking react-native-pdf android dependency
rnpm-install ERR! It seems something went wrong while linking. Error: ENOENT: no such file or directory, open 'C:\React\nsp\NSPV6\NativeStarterPro-v6.0.0\android\app\src\main\java\android\support\v7\appcompat\MainApplication.java'
Please file an issue here: https://github.com/facebook/react-native/issues

ENOENT: no such file or directory, open 'C:\React\nsp\NSPV6\NativeStarterPro-v6.0.0\android\app\src\main\java\android\support\v7\appcompat\MainApplication.java'

I have no problem installing and running your eample on the same win 10 computers, a bit lost.

John

Hi

May be some setting is wrong/non-standard in your android project.

You can manual add the config.

  1. install modules
    npm install react-native-pdf --save
    npm install react-native-fetch-blob --save

  2. add the following code to MainApplication.java

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new RNFetchBlobPackage(),  //add this
            new RCTPdfView()           //add this
      );
    }
  };
  1. add the following code to android/setting.gradle
include ':react-native-pdf'
project(':react-native-pdf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf/android')
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
  1. add the following code to android/app/build.gradle
dependencies {
    compile project(':react-native-pdf')        //add this
    compile project(':react-native-fetch-blob') //add this
}

for detail, you can init a new project and diff with my example project.
Hope this can help you. :-)

Thanks so much for your assistance as a deeper dive indeed fixed the issues.

react-native link failed for me in RN 0.54, these instructions helped a lot!

With reference to issue #2, react-native-fetch-blob has been renamed to rn-fetch-blob since rn-fetch-blob v0.10.9 on June 24th.

Is there any manual Installation for IOS?

react-native link works fine for iOS for me. I will probably use git diff to see the changes in the files to figure out the what react-native link did to manually install it.

Note that react-native-fetch-blob has been renamed to rn-fetch-blob (the README mentions it by the updated name) so you will want to ensure that your settings.gradle and app/build.gradle refer to rn-fetch-blob instead.