Unable to instantiate application com.company.app.MainApplication: java.lang.ClassNotFoundException React Native Expo

Please provide the following:

  1. SDK Version : 45
  2. Platforms(Android/iOS/web/all) : Android
    .

I need help, Please check this topic in stackoverflow I post :

[android - Unable to instantiate application com.company.app.MainApplication: java.lang.ClassNotFoundException React Native Expo - Stack Overflow](https://Need Help In Here)

After I update to the latest Expo SDK i got this error.

Can someone help me find what is the problem ?
Thank You

Hi @daastrading

Does it work with a dev client? Or with the “preview” profile?

What are your dependencies?

I see you’re using the bare workflow. Do you need to?

Hi @wodin ,
It is working when expo run:android with real device or emulator.

But when build with EAS and donwlod the APK then install to my device it got crash.

I try to create a new expo with name myapp. Then I change the package name to com.myapp.myapp similar structure to my package name. Then I use a test lab firebase and it worked.

I don’t know what cause my apps crash with error description in StackOverflow.

Below is my dependencies :

{
  "name": "daastrading",
  "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
}

It is look like some dependencies broke the apps. But I don’t know which one since in worked in development in real device or emulator using expo run:android.

Yes I am using a bare workflow. Because I need it.

If you don’t mind, could you elaborate on why you need the bare workflow?

If it’s for @react-native-firebase/app, I just adding the Google Services JSON/plist files to app.json might be enough, because the Android and iOS versions of the withGoogleServicesFile config plugin should add the necessary things to the native code during the EAS Build process.

No I need this package : react-native-pdf
I need to read a pdf file in my apps without need to download it first. The react-native-pdf doesn’t available for expo managed workflow. From the start creating the apps I have consider to use the Bare Workflow since it can be more free to type the code and add a native code. I also still can use the expo package with bare workflow.

@wodin Did you figure out what is the problem ?

You can use it in the managed workflow using this config plugin:

I’m not saying you have to use the managed workflow. Yes, other Expo stuff should work fine with the bare workflow.

No, sorry, I’m not sure what’s causing the problem. Maybe take that new app and start adding dependencies to it to see when it breaks?

You can use it in the managed workflow using this config plugin:

This one I already try it in managed workflow, I don’t know if my configuration is correct or not. But I have error and it is not working. Anyway, thanks for your reply. I will try your suggestion to take that new app and start adding dependencies to see is there a problem.

I will update the answer here if I found the problem.

Thank You

1 Like

Finally I solve the problem.
I don’t know the exactly solution to solve this problem.
What I do :

  1. Recreate Application using “expo init testing”
  2. Copy package.json from old to new apps.
  3. Build using EAS
  4. Get the AAB file and testing it to Test Lab Firebase. And no error.
  5. Back to new apps. Copy the manifest file from Old to new apps.
  6. Build using EAS
  7. Get the AAB file and testing it to Test Lab Firebase. And no error.
  8. Back to new apps. Copy all source code to new apps.
  9. Build using EAS
  10. 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.

1 Like

I’m glad you managed to solve it!

Maybe you could diff the package-lock.json or yarn.lock files to see if there are any differences there that might help to narrow down the problem. Otherwise, maybe do some comparisons of other native code files.

e.g.:

diff -urN path/to/old/app/android path/to/new/app/android | less

@wodin Thank You. I will check it. But I doubt the problem is not the dependencies package. But I think there are a miss configuration in my expo. Thanks anyway.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.