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

6

10

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"
}
Sandeesandeep answered 5/8, 2021 at 9:25 Comment(5)
please share your error logDarsey
@AftabAmin you can see the log above in this post. Or do you mean anything different?Sandeesandeep
@Sandeesandeep were you able to test your solution in a real device?Hymanhymen
@Hymanhymen sure, I've already published my update even to Google Play alpha channel and it's working.Sandeesandeep
I got the same error, I simply follow the documentation docs.swmansion.com/react-native-reanimated/docs/fundamentals/…Medea
M
4

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.

Maun answered 17/8, 2021 at 22:8 Comment(3)
thanks for the github issue link, after updating reanimated to 2.3.0-alpha.2 my android build is successful now while using react-native 0.65.0Dallas
Please share your podfile. I can't build iOSRama
iOS builds right off the bat for me with RN 0.65. I'm using standard RN template Podfile: github.com/facebook/react-native/blob/main/template/ios/Podfile.Maun
S
2

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 }
Sparker answered 19/8, 2021 at 15:56 Comment(2)
You are using an alpha version of reanimated which happened to include the fix to the issue. It is an alpha release though so most people are not using it. They are most likely still using the latest stable (2.2 as of this moment).Histrionics
well still the Native Emitter problem actually rexzists on alpha just recently as ive tried. I stopped RN for now and gone back to react until they release a stable one's; :)Sparker
G
0

try this:

npm i react-native-reanimated@^1.13.2
Gaygaya answered 5/9, 2021 at 8:45 Comment(1)
What’s the benefit of this over upgrading to Reanimated v.2.3.0-alpha.2, as previous contributors suggested?Streetwalker
T
0

Nothing worked for me so I reinstalled lower version of RN, previously I was working with RN 0.65.1=>

npm install [email protected]

Tilefish answered 9/9, 2021 at 7:8 Comment(0)
S
0

The only version of reanimated which is compatible with react native v65 is v2.3.0-alpha3. Try This

Sharpnosed answered 9/9, 2021 at 13:9 Comment(0)
E
0

Go to android/app/build.gradle and add the following lines of codes:

dependencies {
  implementation 'com.android.support:multidex:2.0.1' //enter the latest multidex version
}
android {
    defaultConfig {
        multiDexEnabled true
    }
}
Extremity answered 31/10, 2022 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.