Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App can not compile #395

Open
jcabrerazuniga opened this issue Mar 10, 2021 · 2 comments
Open

App can not compile #395

jcabrerazuniga opened this issue Mar 10, 2021 · 2 comments

Comments

@jcabrerazuniga
Copy link

After installing and running my app I am getting:

Native module Orientation tried to override OrientationModule. Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true. This error may also be present if the package is present only once in getPackages() but is also automatically added later during build time by autolinking. Try removing the existing entry and rebuild

I am using

"dependencies": {
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-orientation": "^3.1.3",
"react-native-sensors": "^7.2.0",
"rxjs": "^6.6.6"
},

@phelang
Copy link

phelang commented Mar 25, 2021

Issue : Android Platform

I had followed the installation guide form React Native Orientation, and had the error:

Native module Orientation tried to override OrientationModule.

Dependencies

"react-native-orientation": "^3.1.3", "react-native": "^0.64.0",

Solution

Two changes to consider on point three of the guide: 3. Register module in MainApplication.java

  1. Most likely the version of react native 0.64.0 already has import com.github.yamill.orientation.OrientationPackage; so skip this. If you already have imported that might be the reason for duplicate OrientationModule.

  2. In the getPackages() do not add the mentioned line new OrientationPackage() or packages.add(new OrientationPackage()); .

Code Slution

import com.github.yamill.orientation.OrientationPackage;
// import com.github.yamill.orientation.OrientationPackage;  // <--- Should not  Add, comment out or delete

public class MainApplication extends Application implements ReactApplication {
  ......

 @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());

          // packages.add(new OrientationPackage()); //  <------- Should not add, comment out or delete

          return packages;
        }

  ......

}

Gradle

Make sure to clear your gradle caches .\gradlew cleanBuildCache

Additional NOTE: I unlinked or skipped react-native link react-native-orientation

@sumit-android-haridwar
Copy link

Hi Team,
I am also facing this issue from long time.

Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true. This error may also be present if the package is present only once in getPackages() but is also automatically added later during build time by autolinking. Try removing the existing entry and rebuild.
Can anyone have fixed this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants