React-native-orientation: Compilation error on demo project

Created on 12 Mar 2017  路  18Comments  路  Source: yamill/react-native-orientation

I cloned this repo and tried to launch the demo project but got below error:

MainActivity.java:42: error: constructor OrientationPackage in class OrientationPackage cannot be applied to given types;
            new OrientationPackage(this)
            ^
  required: no arguments
  found: MainActivity
  reason: actual and formal argument lists differ in length
1 error

it seems like an compilation error.

My react-native version is 0.27.2

Most helpful comment

use in package.json "react-native-orientation": "git+https://[email protected]/yamill/react-native-orientation.git",

All 18 comments

+1

use in package.json "react-native-orientation": "git+https://[email protected]/yamill/react-native-orientation.git",

I tried to change it in package.json file and run npm install. But still got the same error when run react-native run-android.

Same here. Followed the instructions automatically and manually, and I'm getting the same error:

MainApplication.java:28: error: constructor OrientationPackage in class OrientationPackage cannot be applied to given types;
          new OrientationPackage()
          ^
  required: Activity
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

And it seems that it's failing in here:

// MainApplication.java
public class MainApplication extends Application implements ReactApplication {
...
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new OrientationPackage()       // <---- right here
      );
    }
  };
...

So, I solved my problem by copying the files directly from the repository.

If you guys copied the files via npm or any other package manager, do what I did and everything will compile fine.

@jenkynolasco11 Could you let me know what files did you copy to and from? Thanks.

@joeyzhao0113 I copied this whole repo into my node_modules and it worked perfectly. The version of RN I'm using is 0.42.

I just tried but still the same error. Why doesn't npm install work?

same error

same error

It seems that this project is not working with the latest version of react-native.

Removing the whole directory inside 'npm_modules', adding the Git-Version to 'package.json' and then doing 'npm install' again fixed it for me without a problem!

Tried this with version 0.42

@zhaoyi0113 same issue ,do you figure it out?

@jenkynolasco11 are you sure current react-native-orientation is work?

i saw this file 's construct method is still different from in MainApplication 's call method

https://github.com/yamill/react-native-orientation/blob/master/android/src/main/java/com/github/yamill/orientation/OrientationModule.java

166

We're in the midst of updating and ramping up development in this project. Hoping these incoming fixes will resolve the outstanding issues in this thread.

thank you ,it is surpport rn>4.2 now,right? @andrerfneves

@aqnaruto yes, the package does work with RN 0.40+. Check 5a16ac8a3f96e12969d86a1dd1f6d548efc213b2 commit to see the changes.

thank you ,nice work! handsome!@andrerfneves

Was this page helpful?
0 / 5 - 0 ratings