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
- remove this line:
import com.reactnativenavigation.NavigationActivity;
- Instead add this:
import com.facebook.react.ReactActivity;
- Also, extends from
ReactActivity
, notNavigationActivity
- Update MainApplication.java
- Remove these:
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
- Update this line:
public class MainApplication extends NavigationApplication
to this one:
public class MainApplication extends Application implements ReactApplication {
- Update this line:
new NavigationReactNativeHost(this) {
to this one:
new ReactNativeHost(this) {
onCreate
method:
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false); // add this one
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}