react-native: React Native App Crashes on Launch in Android (API 19)
Description
I have created a project with react-native-cli
When I launch the app using the command “react-native run-android” on Devices and Emulators with Android API level 21+ App is launching.
But for devices less than API 21, the app crashing on launch.
I have specified in android gradle minSdk version to 16.
I viewed the stack trace using “adb logcat” the crash was due to OkHttp3 that is used internally somewhere.
I haven’t used any OkHttp3 Dependency explicitly in my app
React Native version:
6.14.4
Steps To Reproduce
- Create a project using react-native CLI not Expo CLI
- Navigate to the project folder
- Connect a device or an emulator with API less than 21
- run command “react-native run-android” to run app on the connected device
Expected Results
The App should launch without any crash.
Android Logs
E/AndroidRuntime( 3745): java.lang.RuntimeException: Unable to create application com.infifive.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 3745): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4347)
E/AndroidRuntime( 3745): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime( 3745): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime( 3745): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 3745): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 3745): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 3745): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3745): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 3745): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 3745): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 3745): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3745): Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:90)
E/AndroidRuntime( 3745): at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:238)
E/AndroidRuntime( 3745): at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:281)
E/AndroidRuntime( 3745): at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:87)
E/AndroidRuntime( 3745): at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:39)
E/AndroidRuntime( 3745): at com.infifive.MainApplication.onCreate(MainApplication.java:47)
E/AndroidRuntime( 3745): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
E/AndroidRuntime( 3745): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
E/AndroidRuntime( 3745): ... 10 more
E/AndroidRuntime( 3745): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 3745): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 3745): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:80)
E/AndroidRuntime( 3745): ... 17 more
E/AndroidRuntime( 3745): Caused by: java.lang.ExceptionInInitializerError
E/AndroidRuntime( 3745): at okhttp3.OkHttpClient.newSslSocketFactory(OkHttpClient.java:263)
E/AndroidRuntime( 3745): at okhttp3.OkHttpClient.<init>(OkHttpClient.java:229)
E/AndroidRuntime( 3745): at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1015)
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevServerHelper.<init>(DevServerHelper.java:132)
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevSupportManagerImpl.<init>(DevSupportManagerImpl.java:183)
E/AndroidRuntime( 3745): ... 20 more
E/AndroidRuntime( 3745): Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19
E/AndroidRuntime( 3745): at okhttp3.internal.platform.AndroidPlatform.buildIfSupported(AndroidPlatform.java:238)
E/AndroidRuntime( 3745): at okhttp3.internal.platform.Platform.findPlatform(Platform.java:202)
E/AndroidRuntime( 3745): at okhttp3.internal.platform.Platform.<clinit>(Platform.java:79)
Screenshot
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 16 (3 by maintainers)
@Gogul-S I know, I tried to update react-native master dependencies and I re-created this test case in an app that is using react-native from source… but I think that I need to trigger a buck build … react native uses buck to build dependencies
I don’t know buck well so I focus on other issues
https://github.com/facebook/react-native/issues/28481#issuecomment-615359320. Sadly Flipper seems to be only a part of the problem in my app.