cli: MainApplication cannot be converted to ReactNativeHost List packages = new PackageList(this).getPackages();
Environment
System: OS: Linux 4.15 Linux Mint 19.1 (Tessa) CPU: (4) x64 Intel® Core™ i7-6700HQ CPU @ 2.60GHz Memory: 269.00 MB / 4.74 GB Shell: 4.4.19 - /bin/bash Binaries: Node: 10.16.0 - /usr/local/bin/node npm: 6.9.0 - /usr/local/bin/npm npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.0 => 0.60.0 npmGlobalPackages: react-native-cli: 2.0.1
Description
I think PackageList expects ReactNativeHost but i’am using react-native-navigation When i run react-native run-android command i get this error 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/rn/Desktop/denetmenapp/android/app/src/main/java/com/denetmen/MainApplication.java:46: error: incompatible types: MainApplication cannot be converted to ReactNativeHost List<ReactPackage> packages = new PackageList(this).getPackages(); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 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 17s
private ReactNativeHost reactNativeHost;
public PackageList(ReactNativeHost reactNativeHost) {
this.reactNativeHost = reactNativeHost;
}
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
import com.reactnativenavigation.react.ReactGateway;
public class MainApplication extends NavigationApplication {
@Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(),
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add( new DocumentScannerPackage());
packages.add( new CodePush("KEY", getApplicationContext(), isDebug()));
return packages;
}
}
Reproducible Demo
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
import com.reactnativenavigation.react.ReactGateway;
public class MainApplication extends NavigationApplication {
@Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(),
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add( new DocumentScannerPackage());
packages.add( new CodePush("some code thing here”, getApplicationContext(), isDebug()));
return packages;
}
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (10 by maintainers)
the same with @react-native-community/cli@2.8.3 and react-native 0.60.4
@Salakar I managed to run
@guyca i’am getting this error now
/home/rn/Desktop/denetmenapp/android/app/src/main/java/com/denetmen/MainApplication.java:19: error: MainApplication is not abstract and does not override abstract method createAdditionalReactPackages() in NavigationApplication public class MainApplication extends NavigationApplication {
here is my full MainApplication.java