Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native 0.65 (targetSdk=30) android build is failing because of react-native-reanimated

I already upgraded react-native from version 0.64.1 to 0.65.0-rc.3 because targetSdk=30 is required to publish a bundle to Google Play from 1st august 21. I was upgrading letter to letter using upgrade helper Now I am getting ./gradlew bundleRelease error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseAssets'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
   > Failed to transform react-native-reanimated-65-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-assets}.
      > Execution failed for JetifyTransform: MyApp/node_modules/react-native-reanimated/android/react-native-reanimated-65-jsc.aar.
         > Transform's input file does not exist: MyApp/node_modules/react-native-reanimated/android/react-native-reanimated-65-jsc.aar. (See https://issuetracker.google.com/issues/158753935)

Already tried:

  • removing node_modules, reinstalling again
  • cleaning gradle, project, yarn cache, etc...
  • tried to jetify explicitly
  • upgrade android studio
  • upgrade react-native-reanimated to the newest version

Spent hours in frustration that there is no stable release of react-native to proceed through Google requirements. Any ideas to make it work?

----- EDIT ----

As a temporary workaround it's enough to change just versions in the project level gradle file:

ext {
  buildToolsVersion = "30.0.2"
  minSdkVersion = 21
  compileSdkVersion = 30
  targetSdkVersion = 30
  ndkVersion = "20.1.5948944"
}
like image 680
matusalem Avatar asked Aug 05 '21 09:08

matusalem


2 Answers

I have just upgraded to RN 0.65 stable and have the same error on Android. I think it is because it is a little early to upgrade if you want to use react-native-reanimated package v2.0. They probably haven't not upgraded Android to RN 0.65 yet. See similar issue that happened for early upgraders to RN 0.64-rc.1 who used RN Reanimated v. 2.0: https://github.com/software-mansion/react-native-reanimated/issues/1486. We need to wait for RN Reanimated to upgrade their library.

EDIT: Here's the link for RN Reanimated incompatibility with RN 0.65 issue on Github: https://github.com/software-mansion/react-native-reanimated/issues/2290.

EDIT 2: Can confirm that upgrading to RN Reanimated v.2.3.0-alpha.2 solves this problem and Android builds succeed with RN 0.65.

like image 191
PunainenAurinko Avatar answered Nov 15 '22 06:11

PunainenAurinko


Please make sure that you have these modules exactly how they're written in your package.json, else it will fail. I saw a lot of native emitter errors on the react-native-reanimated.

"react": "17.0.2",
"react-native": "0.65",
"react-native-reanimated": "^2.3.0-alpha.2",

Delete your old npm modules. Then run yarn install.

I have tried using the > yarn add react-native-reanimated@next but build failed. my latest build ran on that package.json. I am not too sure about IOS builds.

My build on android was successful as well with these dependencies. I ran problems with npm along the way so I switched to yarn.

I don't know specifically why a lot of people were having errors but mine worked even with the rc3 of react native.

"react-native": "0.65.0-rc.3",
"react-native-reanimated": "^2.3.0-alpha.2",

################################################################

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'Redmi Note 8 Pro - 11' for app:debug
Installed on 1 device.

BUILD SUCCESSFUL in 1m 40s
133 actionable tasks: 110 executed, 23 up-to-date
info Connecting to the development server...
info Starting the app...
Starting: Intent { cmp=com.myapp/.MainActivity }
like image 41
Quarks Avatar answered Nov 15 '22 06:11

Quarks