I have a React-Native project. This project begun with Expo then it has been ejected switched to react-native. the expo libraries is still in use, so I was forced to update expo and migrate from react-native-unimodules to expo modules
I have used all the references available in the bellow links
I have succeeded to let it work on IOS, but on android i am still stuck for hours with the following errors
error: package expo.modules does not exist ...import expo.modules.ApplicationLifecycleDispatcher;
I think that the expo.modules libraries is not initializing on android, even that i have configured all the mentioned steps in Expo documents
Can someone figure out what is the problem
Here is a screen shoot on the list of errors that is appearing
& Here is the mainApplication.java:
package com.myapp.app;
import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import androidx.annotation.NonNull;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
//import com.teamvate.app.generated.BasePackageList;
//import org.unimodules.adapters.react.ModuleRegistryAdapter;
// import org.unimodules.adapters.react.ReactModuleRegistryProvider;
// import org.unimodules.core.interfaces.Package;
// import org.unimodules.core.interfaces.SingletonModule;
//import expo.modules.updates.UpdatesController;
import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
// import javax.annotation.Nullable;
public class MainApplication extends Application implements ReactApplication {
// private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(
// new BasePackageList().getPackageList()
// );
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(this, 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.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
// Packages that cannot be autolinked yet can be added manually here, for example:
packages.add(new ApplicationLifecycleDispatcher());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
// @Override
// protected @Nullable String getJSBundleFile() {
// if (BuildConfig.DEBUG) {
// return super.getJSBundleFile();
// } else {
// return UpdatesController.getInstance().getLaunchAssetFile();
// }
// }
// @Override
// protected @Nullable String getBundleAssetName() {
// if (BuildConfig.DEBUG) {
// return super.getBundleAssetName();
// } else {
// return UpdatesController.getInstance().getBundleAssetName();
// }
// }
});
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
// if (!BuildConfig.DEBUG) {
// UpdatesController.initialize(this);
// }
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.myapp.app.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}