Facing Android Build failure after Nov 4 2022 for React Native?

Android news
BY Mobile Team | Samyak Infotech ON 10 November , 2022

Hello techies, We wonder to share a small story that happened on Monday. It was a production day. We just created an iOS archive and went for a android build. Suddenly it showed a compile time error which we compiled successfully before the November 4, so now it is an Android build failure!

The Nightmare:

The error showed us that “it is an unsupported module found”. We usually face this kind of problem in our react native apps. So, as usual we put the error in google for find out the solution quickly and we ended up with around 10-15 solutions. The mobile team tried to implement these solutions found on stack overflow but none of it worked.

After long research on error, we finally decided to run the old version of the git repo branches but that also didn’t work. After doing too many tricks we finally decided to run our previous versions which was stable on zip backup but that also failed.

We talked about these issues and all scenarios with our project manager and team lead. After knowing this they also got confused and wondered how it can be possible. They gave us some suggestions.

Time was running out for the production. The Backend team was ready for production but the mobile team was  unable to give application because of this serious issue. We thought that this is happening because of the system’s configuration issue. For that reason, we changed our Nodejs version, JDK version and different kind of android studio versions. Still, we were out of luck.

It was around 8 pm and everyone was leaving for home. Our mobile team has decided to accept this challenge and work till we find a solution. We took our MacBook to home and started work on resolving this issue as soon as possible. It had been 15 hours and everyone was frustrated. Because we missed our production and the production was very important to us. We gave so much effort to develop all features and we were still unable to release the application. We worked till 2:30 AM to resolve this issue but we could not make it.

The Next morning, we again started working on that. After so many attempts we finally put our questions to stack overflow. After some time as a reply from stack overflow, we got the same answers which we had already tried. Our vice president got to know about this issue and offered to help us with the contact of an external developer through his network who might have been familiar with his kind of problem. But when we were trying to reach out to him, one of over mobile developers showed an article about the same bug in react native’s GitHub issue page.

The Hope:

This article is “there was an update on a series of build failures for React Native & Expo users have been experiencing when building Android apps starting from November 4th, 2022”. After a whole day of work to find what the actual problem is we found a solution in this article. Finally, the production is released. The actual problem and solution are described below. Happy coding journey!

Android Build Failure Issue:

If you try to run react native project in the android studio then you will get a module not found error like the one below.

  1. Unsupported module detected
  2. No matching variant of com.facebook.react: react-native:0.70.0-rc.0 was found.

Android Build Failure Solution:

  1. React native version >=0.63

Update your react-native version in the package.json file

  1. 0.70.X => 0.70.5
  2. 0.69.X => 0.69.7
  3. 0.68.X => 0.68.5
  4. 0.67.X => 0.67.5
  5. 0.66.X => 0.66.5
  6. 0.65.X => 0.65.3
  7. 0.64.X => 0.64.4
  8. 0.63.X => 0.63.5

To do so, in your package.json change react-native’s version to the relevant new patch (ex. if you are on 0.64.3, change to 0.64.4) and run yarn install. No other changes should be necessary, but you might want to clean your android artifacts with a cd android && ./gradlew clean before trying to re-run your Android app.

  1. React native verson < 0.63

Add the below code in the allprojects area of your android/buld.gradle file.

def REACT_NATIVE_VERSION = new File([‘node’, ‘–print’,”JSON.parse(require(‘fs’).readFileSync(require.resolve(‘react-native/package.json’), ‘utf-8’)).version”].execute(null, rootDir).text.trim())

allprojects {

      configurations.all {

resolutionStrategy {

// Remove this override in 0.65+, as a proper fix is included in react-native itself.

force “com.facebook.react:react-native:” + REACT_NATIVE_VERSION

}

}

//——— rest of code ——–

}

If you are still facing an issue, then Contact Us!

Read more 

  1. https://github.com/facebook/react-native/issues/35210
  2. https://stackoverflow.com/questions/74359824/package-com-facebook-react-does-not-exist#new-answer

Latest News from our end!