Home > front end >  React Native Navigation issues in react native
React Native Navigation issues in react native

Time:08-24

I have installed react-native-navigation package for navigation in react native. After that I didn't like it and try use another package for navigation. But when I tried to uninstall this package and tried to run the app, it gives the following errors as given below. I didn't do anything, I had just uinstalled this react-native-navigation package from npm.

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: S:\Collab\ReactNative\Edesign\node_modules\@react-native-firebase\messaging\android\src\main\java\io\invertase\firebase\messaging\ReactNativeFirebaseMessagingModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:4: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationActivity;
                                ^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:7: error: cannot find symbol
public class MainActivity extends NavigationActivity {
                                  ^
  symbol: class NavigationActivity
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:9: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationApplication;
                                ^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:10: error: package com.reactnativenavigation.react does not exist
import com.reactnativenavigation.react.NavigationPackage;
                                      ^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:35: error: package com.reactnativenavigation.react does not exist
import com.reactnativenavigation.react.NavigationReactNativeHost;
                                      ^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:41: error: cannot find symbol
public class MainApplication extends NavigationApplication {
                                     ^
  symbol: class NavigationApplication
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:11: error: method does not override or implement a method from a supertype
  @Override
  ^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:13: error: cannot find symbol
      super.onCreate(null);
      ^
  symbol:   variable super
  location: class MainActivity
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:44: error: cannot find symbol
      new NavigationReactNativeHost(this) {
          ^
  symbol:   class NavigationReactNativeHost
  location: class MainApplication
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:45: error: method does not override or implement a method from a supertype
        @Override
        ^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:50: error: method does not override or implement a method from a supertype
        @Override
        ^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:53: error: no suitable constructor found for PackageList(<anonymous NavigationReactNativeHost>)   
          List<ReactPackage> packages = new PackageList(this).getPackages();

Is there any solution for this??

CodePudding user response:

After you uninstalled react-native-navigation from npm, you should also revert back installation on Android

  • Update MainActivity.java
  1. remove this line: import com.reactnativenavigation.NavigationActivity;
  2. Instead add this: import com.facebook.react.ReactActivity;
  3. Also, extends from ReactActivity, not NavigationActivity
  • Update MainApplication.java
  1. Remove these:
    import com.reactnativenavigation.NavigationApplication;
    import com.reactnativenavigation.react.NavigationReactNativeHost;
  2. Update this line:
    public class MainApplication extends NavigationApplication
    to this one:
    public class MainApplication extends Application implements ReactApplication {
  3. Update this line:
    new NavigationReactNativeHost(this) {
    to this one:
    new ReactNativeHost(this) {
  4. onCreate method:
@Override
public void onCreate() {
  super.onCreate();
  SoLoader.init(this, /* native exopackage */ false); // add this one
  initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
  • Related