-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
Description
I was using react native version 0.79.0 stable version, and I got a major error that crashed the Android 32-bit architecture device due to turbo module listener.
So I had to update React Native from 0.79.0 to 0.81.X because the community fixed that issue. Now the problem occurs after updating to version 0.81.x, then Android IDE is giving an error on new ReactFragment.Builder().setComponentName this line of code, and it says an ambiguous method, which means the builder class has two functions with the same name, and the compiler is confused to call that function.
ReactFragment fragment = new ReactFragment.Builder()
.setComponentName("HelloWorld") // this line has problem.
.setLaunchOptions(launchOptions)
.build();
And the worst thing I found that I thought it would fix in a later version 0.82.X. I updated again version from 0.81.x to 0.82 latest version and I am getting the following problems;
ReactFragment fragment = new ReactFragment.Builder()
.setComponentName("HelloWorld") // Android IDE says an ambiguous method
.setLaunchOptions(launchOptions) // Android IDE doesn't find this function after the builder, giving an error with red color on the function.
.build();
So in the latest version, Java code has broken for brownfield applications and especially for fragment replacement with React native Screen.
Please guide and fix it. I am stuck
Steps to reproduce
- You can create a new project, or you can use an existing project with version 0.81 or 0.82.x.
- Open the Android folder in Android Studio.
- Open any fragment file which written in java or you can create new file for fragment.
- paste following code in that file
ReactFragment fragment = new ReactFragment.Builder()
.setComponentName("HelloWorld")
.setLaunchOptions(launchOptions)
.build(); - Now you can find the problems, and the IDE will tell ambiguous method call.
React Native Version
0.81.x
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
I have a good machine with 8 cores and 16 threads and having good space.
Stacktrace or Logs
C:\XXX_USER\ExtraProject\XXX-XXX-v2\android\app\src\main\java\hr\sr\recovery\xxx_project\UI\Center\AddOnVehicle\AdddOnFilesFragment.java:71: error: reference to setComponentName is ambiguous
.setComponentName(AppEnums.ReactNativeModule.addOnVehicle.toString())
^
both method setComponentName(String) in Builder and method setComponentName(String) in Builder match
MANDATORY Reproducer
No Play ground please follow above steps to reproduce.
Screenshots and Videos
No response