Last active
March 31, 2020 10:38
-
-
Save mczernek/ae776a50159f4b021309924f2b150436 to your computer and use it in GitHub Desktop.
MainApplication.java changes to support unimodules for RN>=0.60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.doingmything; | |
// "com.doingmything" should be your app package name | |
import com.doingmything.generated.BasePackageList; | |
import android.app.Application; | |
import android.util.Log; | |
import org.unimodules.adapters.react.ModuleRegistryAdapter; | |
import org.unimodules.adapters.react.ReactModuleRegistryProvider; | |
import org.unimodules.core.interfaces.SingletonModule; | |
import com.facebook.react.PackageList; | |
import com.facebook.hermes.reactexecutor.HermesExecutorFactory; | |
import com.facebook.react.bridge.JavaScriptExecutorFactory; | |
import com.facebook.react.ReactApplication; | |
import com.facebook.react.ReactNativeHost; | |
import com.facebook.react.ReactPackage; | |
import com.facebook.soloader.SoLoader; | |
import java.util.Arrays; | |
import java.util.List; | |
public class MainApplication extends Application implements ReactApplication { | |
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList()); | |
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { | |
@Override | |
public boolean getUseDeveloperSupport() { | |
return BuildConfig.DEBUG; | |
} | |
@Override | |
protected List<ReactPackage> getPackages() { | |
@SuppressWarnings("UnnecessaryLocalVariable") | |
List<ReactPackage> packages = new PackageList(this).getPackages(); | |
// Packages that cannot be autolinked yet can be added manually here, for example: | |
// packages.add(new MyReactNativePackage()); | |
// Add unimodules | |
List<ReactPackage> unimodules = Arrays.<ReactPackage>asList( | |
new ModuleRegistryAdapter(mModuleRegistryProvider) | |
); | |
packages.addAll(unimodules); | |
return packages; | |
} | |
@Override | |
protected String getJSMainModuleName() { | |
return "index"; | |
} | |
}; | |
@Override | |
public ReactNativeHost getReactNativeHost() { | |
return mReactNativeHost; | |
} | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
SoLoader.init(this, /* native exopackage */ false); | |
} | |
} |
Oh, I'm also researching that... I think it's because the new React-Native release, for now the most promising reference I found for a fix is this
https://github.com/Diguix/tccFrontend/blob/1af8510183f31e9f2bc119d5a87255d88804df11/android/app/src/main/java/com/tccfrontend/MainApplication.java
also this information is probably the source https://github.com/expo/expo/tree/944c2c3e184539cf06212954f46fb63633fd5bdb/packages/%40unimodules/react-native-adapter
You are right. I've linked incorrect gist, which will be wrking once we publish next version of react-native-unimodules
. Here's the correct one:
https://gist.github.com/mczernek/9de9e184abc430e9e3508d26738c8a14/revisions#diff-a2e7ff8a82f1c4be06f8b8163f2afefa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't compile, error on line https://gist.github.com/mczernek/ae776a50159f4b021309924f2b150436#file-mainapplication-java-L25
ReactModuleRegistryProvider
constructor takes 2 arguments