In short: I am trying to create my own module for a jet project for AndroidPay. AndroidPay integration is possible only using fragments (which are in the final button "Buy from AndroidPay"). So the algorithm is pretty simple, export the placeholder to native-native, wrap it in a component, and at some point just add the fragment to this placeholder using its id. So the code looks like this:
public class AndroidPayPlaceholderViewManager extends SimpleViewManager<FrameLayout>{ public static final String REACT_CLASS = "AndroidPayButton"; public AndroidPayPlaceholderViewManager(ReactApplicationContext context) { super(); } @Override public String getName() { return REACT_CLASS; } @Override protected FrameLayout createViewInstance(ThemedReactContext reactContext) { return (FrameLayout) LayoutInflater.from(reactContext).inflate(R.layout.android_pay_frg_placeholder, null); } }
android_pay_placeholder.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal"> <FrameLayout android:id="@+id/android_pay_placeholder" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal"> </FrameLayout> </FrameLayout>
js component wrapper
import {View, requireNativeComponent} from 'react-native'; import React, {Component} from 'react'; import {NativeModules, findNodeHandle} from 'react-native'; import {isAndroid} from '../utils'; let iface = { propTypes: { ...View.propTypes,
built-in android module, which is responsible for loading the fragment
public class AndroidPayModule extends ReactContextBaseJavaModule implements ActivityEventListener, LifecycleEventListener { .... @ReactMethod public void loadFragment(int placeholderId) { ... WalletFragment mWalletFragment = WalletFragment.newInstance(...);
So, when I add the "placeholder" view to the screen, I see it and even checked using the LayoutInspector, the ID is right:

And the result that I always get is an exception:
java.lang.IllegalArgumentException: No view found for id 0x7f0d00a6 (com.qwerty.playground:id/android_pay_placeholder) for fragment WalletFragment{388fd9c #0 id=0x7f0d00a6} at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:965) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148) at android.app.BackStackRecord.run(BackStackRecord.java:793) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535) at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
So guys, any idea why the FragmentManager cannot just find a view that definitely exists, and maybe some of you did this fragment trick and reacted to your native language and succeeded? Any help would be appreciated! Thanks!