-
Notifications
You must be signed in to change notification settings - Fork 915
MainApplication cannot be converted to ReactNativeHost List<ReactPackage> packages = new PackageList(this).getPackages(); #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can disable auto-link for any given package for android like so (change package name) in root of your app: echo "module.exports = { dependencies: { 'react-native-fbsdk': { platforms: { android: undefined } } } };" > react-native.config.js |
@mikehardy i think this line List packages = new PackageList(this).getPackages() should never work because it's expect ReactNativeHost but when we use react-native-navigation this object (MainApplication) not ReactNativeHost because it's extends from NavigationApplication not extends ReactActivity. Not sure maybe i got it wrong. I need to disable it completely for all packages, not disabled for one package so that the problem can be solved. |
PackageList(this).getPackages() this call causing problem. The this object sent is not the ReactNativeHost object. Sorry for my bad english. |
I knew it, there would be an issue with react native navigation. Hopefully It would get solved quickly. |
Cc @michalchudziak @Salakar @krizzu @ferrannp ideas on how to resolve it on our or native navigation side? It's gonna be pretty common with brownfield apps I guess. |
No need to override @Override
protected ReactNativeHost createReactNativeHost() {
return new NavigationReactNativeHost(this) {
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add( new DocumentScannerPackage());
packages.add( new CodePush("eenqtOmwlGFR_I1wtLjtWujPyDpzSkjLt9tCV", getApplicationContext(), isDebug()));
return packages;
}
};
} |
Maybe I'm wrong, but it seems that these private methods are not really used (unless getters have side effects I'm not aware of): cli/packages/platform-android/native_modules.gradle Lines 20 to 39 in 7220d3e
If that's true, we could remove passing the |
@guyca can you remove CodePush key on your comment and i will try it remove override createReactGateway and let you know if the problem is resolved. |
@thymikee maybe using here /home/rn/Desktop/denetmenapp/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:72: error: cannot find symbol |
@guyca i'am getting this error now here is my full MainApplication.java package com.denetmen;
import android.app.Application;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import androidx.multidex.MultiDex;
import com.documentscanner.DocumentScannerPackage;
import android.content.Context;
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.util.Arrays;
import java.util.List;
import com.microsoft.codepush.react.CodePush;
public class MainApplication extends NavigationApplication {
@Override
protected ReactNativeHost createReactNativeHost() {
return new NavigationReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@javax.annotation.Nullable
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
@Override
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;
}
};
}
@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
} |
They were added for backwards compatibility as some modules use them, e.g. : https://github.com/microsoft/react-native-code-push/blob/master/package.json#L45 |
Hi, just wondering whether you were able to run react native navigation in the latest version or RN (0.6)? |
Hey all, could you try this patch locally (change in node_modules): If all works I'll submit the PR |
Thanks @Salakar! |
@Salakar I managed to run |
@Frekansapp thanks for confirming - PR is now up: #493 |
@thymikee Hi man, did you solve the issue? |
Yup, update the |
@Salakar I am using react-native-community/cli-platform-android "version": "2.8.2" but still facing issue can you please help with this |
@Salakar ```{{ packageImports }} public PackageList(Application application) { |
the same with @react-native-community/[email protected] and react-native 0.60.4
|
Have you tried |
Hello ! Same here, unable to build on RN 0.60.4 with error 'cannot find symbol PackageList' |
@Linoa65 examine line 6 from the android/app/src/main/java/com/rndiffapp/MainApplication.java file here https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.4 I believe you are just missing the import based on your error message, and in general the upgrade helper https://react-native-community.github.io/upgrade-helper/ site is fantastic for upgrades |
Uh oh!
There was an error while loading. Please reload this page.
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.
Execution failed for task ':app:compileDebugJavaWithJavac'.
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
Reproducible Demo
The text was updated successfully, but these errors were encountered: