Android "Cannot convert undefined or null to object"
Hi, I installed android following the instructions here. When I try to do
let PayPal = require('react-native-paypal');
or
import PayPal from 'react-native-paypal';
I get this error:
Cannot convert undefined or null to object
<unknown>
index.js:9
loadModuleImplementation
require.js:122
guardedLoadModule
require.js:65
_require
require.js:49
<unknown>
app.js:3
loadModuleImplementation
require.js:122
guardedLoadModule
require.js:65
_require
require.js:49
<unknown>
index.android.js:11
loadModuleImplementation
require.js:122
My initial thought is that the code added to MainActivity contradicts the one in MainApplication.
The code added to main activity (followed the android setup):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
payPalPackage = new PayPalPackage(this, PAY_PAL_REQUEST_ID); // <--
ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
// ...
.addPackage(payPalPackage) // <--
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
// ...
}
// ...
@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PAY_PAL_REQUEST_ID) {
payPalPackage.handleActivityResult(requestCode, resultCode, data); // <--
} else {
// otherModulesHandlers(requestCode, resultCode, data);
}
}
while the code which is in the MainApplication:
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactMaterialKitPackage(),
new ReactNativePushNotificationPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
Seems to me like MainReactPackage is added twice. Am I right? What am I missing?
Thanks! IY
I see that this is probably an RN > 0.29 problem.. A fix is shown here: https://github.com/mholtzberg/react-native-paypal and here: https://github.com/sharafat/react-native-paypal They should probably be integrated to this repo as well..

I got this running iOS , any suggestions please
Sorry about the lack of support here. If you have fixes you'd like to merge in, please feel free to open a PR, I just haven't had time to maintain this lately.