I installed react native navigation and followed the steps. Works on iOS. Doesn't on android. I get this error when I run react-native run-android, after updating "MainApplication.java" file:
Task :app:compileDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with G radle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings 43 actionable tasks: 2 executed, 41 up-to-date /home/wilux/rnApp/android/app/src/main/java/com/rnApp/MainApplication.java: 17: error: MainApplication is not abstract and does not override abstract method createAdditionalReactPackages() in NavigationApplication public class MainApplication extends NavigationApplication { ^ 1 error
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. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 4s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 /home/wilux/rnApp/android/app/src/main/java/com/rnApp/MainApplication.java:17: error: MainApplication is not abstract and does not override abstract method createAdditionalReactPackages() in NavigationApplication public class MainApplication extends NavigationApplication { ^ 1 error
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. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 4s
at checkExecSyncError (child_process.js:610:11) at execFileSync (child_process.js:628:15) at runOnAllDevices (/home/wilux/rnApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39) at buildAndRun (/home/wilux/rnApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41) at /home/wilux/rnApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12 at processTicksAndRejections (internal/process/task_queues.js:97:5) at async Command.handleAction (/home/wilux/rnApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:164:9)
The strange thing is that it worked when I update "android/build.gradle" and "android/app/build.gradle" files !
Here is the updated file (MainApplication.java) :
package com.rnApp;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
import com.reactnativenavigation.react.ReactGateway;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends NavigationApplication {
@Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
@Override
protected String getJSMainModuleName() {
return "index";
}
};
return new ReactGateway(this, isDebug(), host);
}
@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
// eg. new VectorIconsPackage()
);
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
}
This is a bit of a stab in the dark but for me, 90% of android build problems (especially when you've been modifying native files) can be fixed by executing the gradle clean task by either:
cd android
).\gradlew.bat clean
OSX/Linux: ./gradlew clean
)