Build fails on Android in React Native version 0.64.4 but works pretty well on iOS

  • SDK Version: 44
  • Platform: Android
  • React Native: 0.64.4

It works great also with the other expo modules on iOS without any issues at all but I am so confused why it is not working on Android. I am getting errors that I can’t find any reference related to it. I install the module with the command npx install-expo-modules@latest and check the documentation trying to install it manually but still getting errors.

This is what exactly showing on the terminal when I run ./gradlew build:

cannot find symbol ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED)

Please help :frowning: I need to fix it so bad…

Hi @daryledevs

As a matter of interest, does this need to be a bare app? If so, why? :slight_smile:

Also, how did the app get into this state? Did you upgrade from an earlier Expo SDK version? What else?

Hi! Yes, because the application is actually owned by the company where I am working that I am developing, and I was looking for a module that can generate PDF files for both iOS and Android.

I have never installed Expo before, so basically, this module is fresh from the project. I just following the documentation from: Add Expo to an existing project - Expo Documentation

I have no issue with it. Well, in fact, when I used the module on iOS, it worked flawlessly. However, when I tried it on Android by simply running the command ./gradlew build, it failed and I received the error shown in the image.

Is there anything I could do? Please, I hope there is :frowning:

I see. So this was a plain React Native app and now you’re trying to add some Expo modules to it.

That should definitely work, but I have not tried it myself.

So I assume you installed Expo SDK 44 because the app was built with React Native 0.64.4?

I’m afraid I don’t know why you would be getting the error you’re getting. I’d be interested to know what your dependencies and devDependencies from package.json are and whether any of them have been patched or anything like that. Also, whether the app has any custom native code.

If it doesn’t have custom native code, I’d be tempted to do this:

  • Create a new Expo app (e.g. npx create-expo-app or yarn create expo-app)
  • Install your dependencies using npx expo install xxx. Don’t worry about the JavaScript code yet.
  • Build the app using eas build -p android --profile development

If that builds, then you can add in the JavaScript code.

The Expo SDK 44 was automatically installed after using the documentation’s recommended easiest way to setup with the command: npx install-expo-modules@latest. I confirmed it by starting a new React Native project with the same version and following the documentation’s instructions. The same error from the preceding image was also displayed.

I apologize for not being able to determine whether the app contains any custom native code, and I was also unable to implement the suggested solution because the application was already built and they simply kept adding features to it.

The items listed in ‘package.json’ from the test project are as follows.

{
  "name": "testExpo",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "expo": "^44.0.0",
    "react": "17.0.1",
    "react-native": "0.64.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.12",
    "@babel/runtime": "^7.20.7",
    "@react-native-community/eslint-config": "^3.2.0",
    "babel-jest": "^29.3.1",
    "eslint": "^8.32.0",
    "jest": "^29.3.1",
    "metro-react-native-babel-preset": "^0.74.0",
    "react-test-renderer": "17.0.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

I wonder if it has something to do with the version incompatibility. If so, I wonder why it works on iOS only :frowning:

EDIT:
I think it has nothing to do with version incompability as stated from here: API Reference - Expo Documentation

Hello, @wodin !

I was able to fix it by removing the following function below from the android/app/src/main/java/com/projectName/MainActivity.java:

@Override
  protected ReactActivityDelegate createReactActivityDelegate() {
    return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
      new ReactActivityDelegate(this, getMainComponentName())
    );
  }

Now here it is working on Android:

EDIT:
The function from above was auto generated by the npx install-expo-modules@latest command which is different from the suggested from the documentation here (from android configuration MainActivity.java part): Add Expo to an existing project - Expo Documentation

I am still confused; either way, it doesn’t work, whether it is set up automatically or manually.

All in all, thank you for replying on my queries!!

1 Like