Skip to content

Instantly share code, notes, and snippets.

@kageurufu
Created August 17, 2016 20:11
Show Gist options
  • Save kageurufu/79e4aaa1c41cbdb147e936d7e473029d to your computer and use it in GitHub Desktop.
Save kageurufu/79e4aaa1c41cbdb147e936d7e473029d to your computer and use it in GitHub Desktop.
Fix for react-native#9319
// Add the following imports and methods in their respective places
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.LifecycleState;
public class MainApplication extends Application implements ReactApplication {
protected Application getApplication() { return this; }
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected ReactInstanceManager createReactInstanceManager() {
ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
.setUseOldBridge(true)
.setApplication(getApplication())
.setJSMainModuleName(getJSMainModuleName())
.setUseDeveloperSupport(getUseDeveloperSupport())
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
for (ReactPackage reactPackage : getPackages()) {
builder.addPackage(reactPackage);
}
String jsBundleFile = getJSBundleFile();
if (jsBundleFile != null) {
builder.setJSBundleFile(jsBundleFile);
} else {
builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
}
return builder.build();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment