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
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
^
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;
}
}
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;
}
}
You can disable auto-link for any given package for android like so (change package name) in root of your app:
https://github.com/mikehardy/rn-androidx-demo/commit/51d1e70fe074af29c1d1f8948d8f03b76e828b9f#diff-c8e33fe90e78d567b713e8dab48e5d87R56
echo "module.exports = { dependencies: { 'react-native-fbsdk': { platforms: { android: undefined } } } };" > react-native.config.js
@mikehardy i think this line List
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 createReactGateway - just override the method which creates the host:
@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):
https://github.com/react-native-community/cli/blob/7220d3ef19e9344e6e3d10863a9090ac9ac729ef/packages/platform-android/native_modules.gradle#L20-L39
If that's true, we could remove passing the ReactNativeHost entirely.
@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
new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG), but it's throw error and i remove autolinking for codepush and add manuel
/home/rn/Desktop/denetmenapp/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:72: error: cannot find symbol
new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
^
symbol: variable reactNativeCodePush_androidDeploymentKey
location: class string
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
@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
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);
}
}
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):
https://github.com/react-native-community/cli/blob/7220d3ef19e9344e6e3d10863a9090ac9ac729ef/packages/platform-android/native_modules.gradle#L20-L39If that's true, we could remove passing the
ReactNativeHostentirely.
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
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):
https://github.com/react-native-community/cli/blob/7220d3ef19e9344e6e3d10863a9090ac9ac729ef/packages/platform-android/native_modules.gradle#L20-L39If that's true, we could remove passing the
ReactNativeHostentirely.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):
https://github.com/react-native-community/cli/compare/@salakar/android-al-mainapplication?expand=1#diff-375026a0607eb034a6fc70cca7d74689
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 @react-native-community/cli to the latest version to get the fix.
@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 class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
public PackageList(ReactNativeHost reactNativeHost) {
this.reactNativeHost = reactNativeHost;
}
public PackageList(Application application) {
this.reactNativeHost = null;
this.application = application;
}
private ReactNativeHost getReactNativeHost() {
return this.reactNativeHost;
@@ -31,6 +37,7 @@ public class PackageList {
}
private Application getApplication() {
if (this.reactNativeHost == null) return this.application;
return this.reactNativeHost.getApplication();
}```
the same with @react-native-community/[email protected] and react-native 0.60.4
/android/app/src/main/java/com/emphy/MainApplication.java:7: error: cannot find symbol
import com.facebook.react.PackageList;
^
symbol: class PackageList
location: package com.facebook.react
/Users/irynapolishchuk/mobile/android/app/src/main/java/com/emphy/MainApplication.java:45: error: cannot find symbol
List<ReactPackage> packages = new PackageList(this).getPackages();
^
symbol: class PackageList
2 errors
FAILURE: Build failed with an exception.
Have you tried yarn react-native run-android --tasks clean or cd android && ./gradlew clean and then building again?
Hello !
Same here, unable to build on RN 0.60.4 with error 'cannot find symbol PackageList'
I'm currently upgrading my app, it's such a pain to resolve all conflict/dependencies problems...
@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
the same with @react-native-community/[email protected] and react-native 0.60.4
/android/app/src/main/java/com/emphy/MainApplication.java:7: error: cannot find symbol import com.facebook.react.PackageList; ^ symbol: class PackageList location: package com.facebook.react /Users/irynapolishchuk/mobile/android/app/src/main/java/com/emphy/MainApplication.java:45: error: cannot find symbol List<ReactPackage> packages = new PackageList(this).getPackages(); ^ symbol: class PackageList 2 errors FAILURE: Build failed with an exception.
@Override
protected List
return Arrays.
new MainReactPackage(),
new ReanimatedPackage(),
new RNGestureHandlerPackage(),
new RNScreensPackage(),
new YourCustomPackage(),
new ModuleRegistryAdapter(mModuleRegistryProvider)
);
}
worked for me instead of using PackageList
Most helpful comment
the same with @react-native-community/[email protected] and react-native 0.60.4