Need help here, please help. I cannot find what cause my app cannot run in production release. I use Expo Bare Workflow
When I run expo run:android it success and the application is build and run normaly in my real device.
But when I launch to the open testing using eas build --platform android It create aab file. And I upload it to the google play console. I download the apk file and install to my device. Then the apps crash.
I try using the Test Lab Firebase to check the issue. And this is the error provide by the Test Lab Firebase
java.lang.RuntimeException: Unable to instantiate application com.company.app.MainApplication: java.lang.ClassNotFoundException: Didn't find class "com.company.app.MainApplication" on path: DexPathList[[zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/base.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.arm64_v8a.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.en.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/lib/arm64, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/base.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.en.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
FATAL EXCEPTION: main
Process: com.company.app, PID: 26110
java.lang.RuntimeException: Unable to instantiate application com.company.app.MainApplication: java.lang.ClassNotFoundException: Didn't find class "com.company.app.MainApplication" on path: DexPathList[[zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/base.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.arm64_v8a.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.en.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/lib/arm64, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/base.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.en.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1268)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6690)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7664)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.company.app.MainApplication" on path: DexPathList[[zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/base.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.arm64_v8a.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.en.apk", zip file "/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/lib/arm64, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/base.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.en.apk!/lib/arm64-v8a, /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
at android.app.Instrumentation.newApplication(Instrumentation.java:1158)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1260)
... 9 more
Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.arm64_v8a.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:367)
at dalvik.system.DexFile.<init>(DexFile.java:109)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:439)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:398)
at dalvik.system.DexPathList.<init>(DexPathList.java:166)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:129)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:104)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:898)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:982)
at android.app.LoadedApk.getResources(LoadedApk.java:1214)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2663)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2655)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6602)
... 8 more
Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.en.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:367)
at dalvik.system.DexFile.<init>(DexFile.java:109)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:439)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:398)
at dalvik.system.DexPathList.<init>(DexPathList.java:166)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:129)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:104)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:898)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:982)
at android.app.LoadedApk.getResources(LoadedApk.java:1214)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2663)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2655)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6602)
... 8 more
Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/~~r6re0ia8oZr-bYYdxRcPtg==/com.company.app-gpnpC_W8RMut_6tG9AHRPA==/split_config.xxhdpi.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:367)
at dalvik.system.DexFile.<init>(DexFile.java:109)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:439)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:398)
at dalvik.system.DexPathList.<init>(DexPathList.java:166)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:129)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:104)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:898)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:982)
at android.app.LoadedApk.getResources(LoadedApk.java:1214)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2663)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2655)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6602)
... 8 more
This is my folder structure :
This is my AndroidManifest.xml file :
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.app">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"/>
</intent>
</queries>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
<meta-data android:name="expo.modules.updates.EXPO_RELEASE_CHANNEL" android:value="default"/>
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="45.0.0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@daastrading/daas-trading"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground" android:value="false"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@color/white"/>
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="com.company.app"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher"/>
<receiver android:exported="false" android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
This is my MainApplication.java :
package com.company.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.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.soloader.SoLoader;
import com.company.app.newarchitecture.MainApplicationReactNativeHost;
import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
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 that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
});
private final ReactNativeHost mNewArchitectureNativeHost =
new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
@Override
public ReactNativeHost getReactNativeHost() {
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
return mNewArchitectureNativeHost;
} else {
return mReactNativeHost;
}
}
@Override
public void onCreate() {
super.onCreate();
// If you opted-in for the New Architecture, we enable the TurboModule system
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
SoLoader.init(this, /* native exopackage */ false);
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.company.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();
}
}
}
}
I used the latest Expo SDK : 45 and React-Native : 0.68.2
I search in the google try to find the issues related to the error. So many people got a different error related to java.lang.ClassNotFoundException But It not solve my problem. I cannot find the exactly same with my error in google. What could possible the issue to my error ?
What is the error mean ? How to fix it ? Is there something I have missed it ? Because running in emulator or real device in development mode Is Worked. My apps got pending to launch because of this issue. I have no other error.
Thank You.
Note : I change all my package name to com.company.app for security reason. The real package name is like : com.testing.testing which testing is not my real package name.
Edit :
This is my dependencies :
{
"name": "testing",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-native-community/datetimepicker": "6.1.2",
"@react-native-community/netinfo": "8.2.0",
"@react-native-community/push-notification-ios": "^1.10.1",
"@react-native-firebase/app": "^14.9.0",
"@react-native-masked-view/masked-view": "0.2.6",
"@react-navigation/bottom-tabs": "^6.2.0",
"@react-navigation/drawer": "^6.3.1",
"@react-navigation/material-top-tabs": "^6.1.1",
"@react-navigation/native": "^6.0.8",
"@react-navigation/native-stack": "^6.5.0",
"@reduxjs/toolkit": "^1.8.0",
"accordion-collapse-react-native": "^1.1.0",
"axios": "^0.26.0",
"buffer": "^6.0.3",
"crypto-js": "^4.1.1",
"expo": "^45.0.0",
"expo-app-loading": "~2.0.0",
"expo-asset": "~8.5.0",
"expo-auth-session": "~3.6.1",
"expo-constants": "~13.1.1",
"expo-crypto": "~10.2.0",
"expo-file-system": "~14.0.0",
"expo-linking": "~3.1.0",
"expo-random": "~12.2.0",
"expo-screen-orientation": "~4.2.0",
"expo-sharing": "~10.2.0",
"expo-sqlite": "~10.2.0",
"expo-updates": "~0.13.1",
"expo-web-browser": "~10.2.1",
"fbjs": "^3.0.4",
"lodash": "^4.17.21",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-google-mobile-ads": "^6.3.0",
"react-native-web": "0.17.7",
"react-native-blob-util": "^0.15.0",
"react-native-device-info": "^8.7.0",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "~2.2.1",
"react-native-image-pan-zoom": "^2.1.12",
"react-native-pager-view": "5.4.15",
"react-native-paper": "^3.12.0",
"react-native-pdf": "^6.4.0",
"react-native-push-notification": "^8.1.1",
"react-native-reanimated": "~2.8.0",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "^3.4.1",
"react-native-screens": "~3.11.1",
"react-native-slider": "^0.11.0",
"react-native-snap-carousel": "^3.9.1",
"react-native-tab-view": "^3.1.1",
"react-native-toast-message": "^2.1.1",
"react-native-webview": "11.18.1",
"react-redux": "^7.2.6",
"redux": "^4.1.2",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.4.1"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
CodePudding user response:
Finally I solve the problem. I don’t know the exactly solution to solve this problem. What I do :
- Recreate Application using “expo init testing”
- Copy package.json from old to new apps.
- Build using EAS Get the AAB file and testing it to Test Lab Firebase. And no error
- Back to new apps. Copy the manifest file from Old to new apps.
- Build using EAS Get the AAB file and testing it to Test Lab Firebase. And no error.
- Back to new apps. Copy all source code to new apps. Build using EAS Get the AAB file and testing it to Test Lab Firebase. And no more error.
And Finally solve the problem. But I still don’t know what I have missed in the previous version of my apps. But now it is working. So I will mark as solution