📌  相关文章
📜  在 react native 裸项目上安装 expo - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:51:14.133000             🧑  作者: Mango

代码示例1
npm install react-native-unimodules

Configuation ANDROID:

android/app/build.gradle :
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
addUnimodulesDependencies()

android/app/src/main/java/com/myapp/MainApplication.java :
import com.myapp.generated.BasePackageList;
import java.util.Arrays;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.SingletonModule;

public class MainApplication extends Application implements ReactApplication {
  //Add the line below as a class variable
  private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null);
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
      @Override
      public boolean getUseDeveloperSupport() {
        protected List getPackages() {
            //Add thoses lines(24 to 27) below in the getPackages function
            List unimodules = Arrays.asList(
                new ModuleRegistryAdapter(mModuleRegistryProvider)
              );
              packages.addAll(unimodules);
           }
    }
}

android/build.gradle :
minSdkVersion = 21

android/settings.gradle :
apply from: '../node_modules/react-native-unimodules/gradle.groovy';
includeUnimodulesProjects()