react-native: 0.62.0 Android API level 16 broken: Flipper
Description
When I run a new react native v0.62.0 Android app, it broken
React Native version:
System:
OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 1.03 GB / 15.38 GB
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 12.14.0 - /tmp/yarn--1585763432742-0.5895315424087944/node
Yarn: 1.21.1 - /tmp/yarn--1585763432742-0.5895315424087944/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v12.14.0/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 16, 28, 29
Build Tools: 28.0.3, 29.0.3
System Images: android-16 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.0 => 0.62.0
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Use an API 16 Android emulator
npx react-native init AwesomeProject
yarn react-native run-android
- Wait
- App broken
- Check logcat (
adb logcat | grep 'AndroidRuntime'
)
E/AndroidRuntime( 5079): java.lang.RuntimeException: Unable to create application com.awesometsproject.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 5079): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4154)
E/AndroidRuntime( 5079): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
E/AndroidRuntime( 5079): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
E/AndroidRuntime( 5079): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5079): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 5079): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 5079): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5079): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 5079): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 5079): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 5079): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5079): Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 5079): at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:90)
E/AndroidRuntime( 5079): at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:238)
E/AndroidRuntime( 5079): at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:281)
E/AndroidRuntime( 5079): at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:87)
E/AndroidRuntime( 5079): at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:39)
E/AndroidRuntime( 5079): at com.awesometsproject.MainApplication.onCreate(MainApplication.java:47)
E/AndroidRuntime( 5079): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
E/AndroidRuntime( 5079): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
E/AndroidRuntime( 5079): ... 10 more
E/AndroidRuntime( 5079): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 5079): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 5079): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/AndroidRuntime( 5079): at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:80)
E/AndroidRuntime( 5079): ... 17 more
E/AndroidRuntime( 5079): Caused by: java.lang.NoClassDefFoundError: java.util.Objects
E/AndroidRuntime( 5079): at okhttp3.CertificatePinner.withCertificateChainCleaner(CertificatePinner.java:231)
E/AndroidRuntime( 5079): at okhttp3.OkHttpClient.<init>(OkHttpClient.java:238)
E/AndroidRuntime( 5079): at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1015)
E/AndroidRuntime( 5079): at com.facebook.react.devsupport.DevServerHelper.<init>(DevServerHelper.java:132)
E/AndroidRuntime( 5079): at com.facebook.react.devsupport.DevSupportManagerImpl.<init>(DevSupportManagerImpl.java:183)
E/AndroidRuntime( 5079): ... 20 more
W/ActivityManager( 1456): Force finishing activity com.awesometsproject/.MainActivity
Note: If I comment the source Flipper source, the error disappears when the specific dependency is commented
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
Expected Results
App starts in Android API 16
Snack, code example, screenshot, or link to a repository:
Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 20 (4 by maintainers)
Commits related to this issue
- Exclude okhttp from flipper dependency (#29260) Summary: This fixes https://github.com/facebook/react-native/issues/28481. As explained in [this comment](https://github.com/facebook/react-native/issu... — committed to facebook/react-native by Shywim 4 years ago
- flipper android: Follow RN's exclusion of okhttp from a Flipper dependency. Part of the RN v0.62 -> v0.63 changes to the template app [1], corresponding to facebook/react-native@a642c3f26. This seem... — committed to chrisbobbe/zulip-mobile by chrisbobbe 4 years ago
- flipper android: Follow RN's exclusion of okhttp from a Flipper dependency. Part of the RN v0.62 -> v0.63 changes to the template app [1], corresponding to facebook/react-native@a642c3f26. This seem... — committed to chrisbobbe/zulip-mobile by chrisbobbe 4 years ago
So, after messing around with gradle and looking at the dependencies of a bare React Native project, the culprit is Flipper with an explicit dependency on okhttp 3.14.1 which will not function on Android API < 21, the last working version being 3.12.1 which is the version React Native is dependent on.
I fixed it in our projects by excluding okhttp from the
flipper-network-plugin
dependency and now we can run the debug build on every Android version without removing flipper:Looking at facebook/flipper#1037, it looks like it’s not something the Flipper team will change, so if the React Native team is willing to continue supporting older version of android (
minSdkVersion
is still16
while writing this) maybe it should be integrated in the template.On app/build.gradle comment out:
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' }
Delete or comment out all the code in android/app/src/debug/…/ReactNativeFlipper.java
In MainApplication.java comment out:
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
Idk if its overkill but it worked for me.
@Shywim you are right! 💯 Excluding
okhttp3
from theflipper-network-plugin
get’s rid of this error.Also thanks for submitting the PR! Looks like it got merged in here https://github.com/facebook/react-native/commit/a642c3f264e31f3c2a80a70c1fb7baa2325f4e5e and will be available in the next release! 👍
If solution given by @juanamd works, I believe the only problem is with flipper. And we all know “adb reverse” does works only with Android version 5.0 and above maybe flipper has to do something with it. I believe flipper should automatically disable itself when working with android version below 5.0.
I am facing the same issue…
I looking for this solution. It’s works well. Thanks!!!
which file to edit?
@Shywim just ran into this and as a mostly-android-native developer your solution looks right. This looks like a group policy problem between the flipper and react-native teams where they have different minimum APIs to support. That’s fine as far as it goes but not if the default init template from react-native crashes on devices that are supposed to be supported. You should propose the PR to the react-native template for consideration with a comment in the change indicating when it can be removed (minSdkVersion >= 21) - if you don’t I will but the internet points are there for the taking 😃
(I will note that okhttp 3.12.12 works fine on android API16 and above - I use it another app that still has tens of thousands of users on those old devices. It’s the 3.12.x branch that is important, not 3.12.1 specifically in my experience)
We experienced KitKat devices not being able to connect via HTTPS since April 1st 2020 without any app updates. Our app does not use react native, but I think the issue is still similar. My guess is that the TLS Cipher cannot be created anymore. I don’t know why and I have not found anything official to the cipher lifetimes, yet. So maybe that’s something y’all can also look into? Because it seems as if react native tries to create the Ciphers at app start.