Skip to content

MainApplication cannot be converted to ReactNativeHost List<ReactPackage> packages = new PackageList(this).getPackages(); #467

Description

@erennyuksell

Environment

System:
OS: Linux 4.15 Linux Mint 19.1 (Tessa)
CPU: (4) x64 Intel(R) Core(TM) 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 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;
       
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions