not working on android – undefined is not an object

I followed the example in the readme (tried both manual installation and automatic) and no matter what I do, when I press the share button Share.open always fails with:
undefined is not an object (evaluating '_reactNativeShare2.default.open')

building on Ubuntu 14.04 64-bit and running on Android 5.0.1

1 possible answer(s) on “not working on android – undefined is not an object

  1. Yes, rnpm link doesn’t work. In React Native >= 0.29 you need:

    Android

    1. npm install react-native-share --save

    2. Open up android/app/src/main/java/[...]/MainApplication.java

      • Add import cl.json.RNSharePackage; to the imports at the top of the file
      • Add new RNSharePackage() to the list returned by the getPackages() method
    3. Append the following lines to android/settings.gradle:
      include ':react-native-share' project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')

    4. Insert the following lines inside the dependencies block in android/app/build.gradle:

      ```
      compile project(':react-native-share')
      ```
      

not working on android – undefined is not an object

I followed the example in the readme (tried both manual installation and automatic) and no matter what I do, when I press the share button Share.open always fails with:
undefined is not an object (evaluating '_reactNativeShare2.default.open')

building on Ubuntu 14.04 64-bit and running on Android 5.0.1

4 thoughts on “not working on android – undefined is not an object

  1. Yes, rnpm link doesn’t work. In React Native >= 0.29 you need:

    Android

    1. npm install react-native-share --save

    2. Open up android/app/src/main/java/[...]/MainApplication.java

      • Add import cl.json.RNSharePackage; to the imports at the top of the file
      • Add new RNSharePackage() to the list returned by the getPackages() method
    3. Append the following lines to android/settings.gradle:
      include ':react-native-share' project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')

    4. Insert the following lines inside the dependencies block in android/app/build.gradle:

      ```
      compile project(':react-native-share')
      ```