react-native-file-selector icon indicating copy to clipboard operation
react-native-file-selector copied to clipboard

Undefined is not an object RNFileSelector.Show

Open GunaSekhar1 opened this issue 7 years ago • 5 comments

Hi,

I have installed the library using "npm install react-native-file-selector --save"

In android/app/build.gradle I have added the below lines

repositories { maven { url "http://dl.bintray.com/lukaville/maven" } maven { url "https://maven.google.com" } } allprojects { repositories { mavenLocal() jcenter() maven { url "https://maven.google.com" } } }

I have imported import RNFileSelector from 'react-native-file-selector'; in js file

on click of button calling

RNFileSelector.Show( { title: 'Select File', onDone: (path) => { console.log('file selected: ' + path) }, onCancel: () => { console.log('cancelled') } } );

I am getting "undefined is not an object RNFileSeector.Show"

Am I doing anything wrong?

GunaSekhar1 avatar Sep 25 '18 09:09 GunaSekhar1

Thanks @GunaSekhar1 for raising the issue.

Looks like the library is not linked properly. Can you please try below installation steps:

  • react-native link react-native-file-selector

  • Add below snippet in your app build.gradle file

repositories {
    maven {
        url  "http://dl.bintray.com/lukaville/maven"
    }
    maven { url "https://maven.google.com" }
    ...
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "https://maven.google.com" }
        ...
    }
}
  • Add below color attributes in your app res/color.xml. You can provide your own color codes
    <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>

Thanks </ Pranav >

prscX avatar Oct 14 '18 08:10 prscX

i am getting the same in IOS and i have done all the linking options. help me.

reactdevrocks avatar Nov 26 '18 08:11 reactdevrocks

i am getting the same in IOS and i have done all the linking options.

zgx33 avatar Jan 02 '19 08:01 zgx33

I fixed it by adding this:

Add implementation project(':react-native-file-selector') to dependencies block of yourfolder/android/app/build.gradle.

Add this code to yourfolder/android/app/src/main/java/com/<your-company>/<app-name>/MainApplication.java

import ui.fileselector.RNFileSelectorPackage;
....
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        ........
        new RNFileSelectorPackage()
  );
}

Add this to yourfolder/android/settings.gradle

include ':react-native-file-selector'
project(':react-native-file-selector').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-selector/android')

Somehow this code is not get populated during linking (react-native link react-native-file-selector)

KonstantinKolodnitsky avatar Jan 07 '19 04:01 KonstantinKolodnitsky

i am getting the same in IOS and i have done all the linking options. help me.

suwu150 avatar Jan 22 '19 15:01 suwu150