React Native App crashes on android 11 on launch without giving error
Asked Answered
I

2

9

enter image description here

this is my build.gradle setting and this is my system info enter image description here

I'm trying to run the react native app on android 11 but it is keep crashing on launch without giving any error I have tries almost every solution including setting in build.gradle

buildToolsVersion = "30.0.0"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "30.0.0"
ndkVersion = "20.1.5948944"
multiDexEnabled = true

setting ** target API to"30" ** in AndroidManifest.xml

the Gradle version I'm using is Gradle plugin version is 4.1.3 Gradle version is 6.7**

please help me find the solution in this regard thanks

Irreligious answered 15/6, 2021 at 7:56 Comment(0)
C
12

I got an error like this when setting targetSdk version to 30 it's happening because of okhttp version and fixed it by using the latest version

implementation("com.squareup.okhttp3:okhttp:4.9.1")
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.1")

add this in your android/app/build.gradle

Clovah answered 11/8, 2021 at 15:1 Comment(6)
Where in the bundle should I add this?Gargan
The way is not update the okhttp version. Just update react-native version. This issue was solved in github.com/facebook/react-native/pull/29741 To update react-native version you can use: npx react-native upgradeMeier
@RogerCruz you should add this in your android/app/build.gradle, I have mentioned this in the answerClovah
@JulianCorrêa, This issue was happening in the latest stable react native, You have mentioned about an old PR which was increasing okhttp to version 3 but with this issue you need to increase it to version 4Clovah
@Clovah About the PR, you're right. So, I build a app and sent to production a few days ago using RN 0.66.3, and this issue was solved. I didnt any change about okhttp. Change the version of libs that are used inside of core of react is not a good solution, but some times its necessary, in this case you must inform that solution is temporary, palliative. Am I wrong? I just test (debug and release) right now a fresh new project on my Device with Android 11 and there is no crash anymore.Meier
For me works with implementation("com.squareup.okhttp3:okhttp:4.9.2")Cairn
D
7

This answer has been provided by manohar-octifi (github discussion):

If you are using @sentry/react-native and the version is lower than 2.0.0, then update the version to 2.0.0 or higher (I updated to 2.2.0). This should fix the problem.

Dicarlo answered 20/11, 2021 at 21:7 Comment(2)
You saved my life, I was using an old Sentry version. Thank you!Umbel
I am very glad to hear! :)Dicarlo

© 2022 - 2024 — McMap. All rights reserved.