react-native-threads icon indicating copy to clipboard operation
react-native-threads copied to clipboard

On RN 61 we have errors.

Open neller1 opened this issue 6 years ago • 6 comments

Because netinfo module was deleted in RN 61 we have error: ThreadBaseReactPackage.java:13: error: package com.facebook.react.modules.netinfo does not exist

I commented 13 and 49 strings in ThreadBaseReactPackage.java to temporary start project

neller1 avatar Sep 26 '19 07:09 neller1

I've done this, but I get a compile error

/TestNative/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:51: error: constructor RNThreadPackage in class RNThreadPackage cannot be applied to given types;
      new RNThreadPackage()
      ^
  required: ReactNativeHost,ReactPackage[]
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error

FAILURE: Build failed with an exception.

I've definitely added the relevant lines to getPackages - here's a cut/paste

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          packages.add(new RNThreadPackage(mReactNativeHost));
          return packages;
       }

Any suggestions?

dwhitney avatar Sep 26 '19 20:09 dwhitney

The same problem. Tried to use tarball version - "react-native-threads": "http://github.com/joltup/react-native-threads/tarball/master"

but it leads to the same error: "error: package com.facebook.react.modules.netinfo does not exist import com.facebook.react.modules.netinfo.NetInfoModule;"

Do we plan to update rnt for 61? Or maybe there are alternatives?

minicuper avatar Oct 02 '19 05:10 minicuper

Found how to do the trick.

  1. use https://github.com/jhen0409/react-native-threads/tree/rn61 (or just remove 13 and 49 lines as in the first topic) yarn add http://github.com/jhen0409/react-native-threads/tarball/rn61
    or npm i http://github.com/jhen0409/react-native-threads/tarball/rn61

  2. manually link the package react-native link react-native-threads

  3. turn off linking for android (according to https://github.com/joltup/react-native-threads/pull/76 and https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library)

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-threads': {
      platforms: {
        android: null, 
      },
    },
  },
};

Dirty hacks but working...

minicuper avatar Oct 02 '19 11:10 minicuper

So, now we have 2 issues to get 61:

  1. need to remove netinfo package (the 13, 49 lines in the ThreadBaseReactPackage.java)
  2. somehow setup auto-linking for 61 (taking into account that RNThreadPackage requires additional parameters: at least ReactNativeHost + additional native packages that should be available in the Thread)

minicuper avatar Oct 02 '19 11:10 minicuper

#84

ihavenoface5 avatar Oct 04 '19 01:10 ihavenoface5

I was able to fix this by adding this file to the root,

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-threads': {
      platforms: {
        android: null, 
      },
    },
  },
};

And then just following the manual linking step. I didn't need to use another repo, this one worked fine with the above

jacobp100 avatar Nov 27 '19 13:11 jacobp100