Fresh Install Android Broken on React Native 0.60 RC2
See original GitHub issueAs React Native will default to AndroidX from 0.60, I want to upgrade my project to 0.60RC2 and AndroidX but I can’t get it to working. I can reproduce it with a fresh project.
React Native version:
System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Memory: 67.11 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.4.0 - /usr/local/bin/node
Yarn: 1.17.0 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.60.0-rc.2 => 0.60.0-rc.2
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
- Create a new React Native Project
react-native init testproject
(it creates a project using"react-native": "0.59.9"
dependency). - Make sure your emulator is running. Try to run
cd /Users/Can/Desktop/testproject && react-native run-android
(replace path with yours). - In my case it couldn’t find the Android SDK, so I added
local.properties
intoandroid
folder with the contentsdk.dir=/Users/Can/Library/Android/sdk
(replace it with your Android SDK path) - Run
react-native run-android
again. It runs perfectly. It displays the default Hello World app screen on my emulator. - Open
package.json
and switch RN version to 0.60 RC2:"react-native": "0.60.0-rc.2"
- Run
npm install
to update to latest version. - Try running
react-native run-android
again. It errorsTask :app:processDebugManifest FAILED
:
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.
What I’ve tried:
- As the error message suggests, I’ve added
tools:replace="android:appComponentFactory"
toapplication
tag in my project’s rootAndroidManifest.xml
and tried running again. Then I got a different error:
> org.xml.sax.SAXParseException; systemId: file:/Users/Can/Desktop/testproject/android/app/src/main/AndroidManifest.xml; lineNumber: 13; columnNumber: 39; The prefix "tools" for attribute "tools:replace" associated with an element type "application" is not bound.
After a quick Googling I’ve found this comment where it suggests to add xmlns:tools="http://schemas.android.com/tools"
to the manifest’s root tag, so I did it. When I ran, this time I got:
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/Can/Desktop/testproject/android/app/src/main/AndroidManifest.xml:6:5-25:19 Error:
tools:replace specified at line:6 for attribute android:appComponentFactory, but no new value specified
After Googling that too I’ve stumbled upon a StackOverflow question regarding the same issue with this answer: It tells, if migrating to AndroidX (which RN 0.60 uses by default), to remove those tags from manifest and add the following lines to gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
So I did those. Now, the build succeeds on RN 0.60, but immedieately at launch I’m getting the following error in LogCat and the app crashes on launch:
2019-06-27 23:30:34.151 8014-8047/com.testproject E/SoLoader: Error when loading lib: dlopen failed: library "libjsc.so" not found lib hash: 9f147276937ca9f5dfbf5ff8b8b470c1 search path is /data/app/com.testproject-LdIs8_kVqRM_R_hH6wP35g==/lib/x86
2019-06-27 23:30:34.152 8014-8047/com.testproject E/SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
--------- beginning of crash
2019-06-27 23:30:34.156 8014-8047/com.testproject E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.testproject, PID: 8014
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
at com.facebook.react.jscexecutor.JSCExecutor.<clinit>(JSCExecutor.java:19)
at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:29)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
at java.lang.Thread.run(Thread.java:764)
I’ve then Googled dlopen failed: library "libjsc.so" not found
and stumbled upon someone having the same issue after upgrading to 0.60 RC2. I’ve tried the accepted answer and added def useIntlJsc = false
to the top of app/build.gradle
and the following snippet into dependencies:
if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+'
} else {
implementation 'org.webkit:android-jsc:+'
}
At this point nothing changed and I keep getting the same error. In addition to the steps above, (I know the following is unreproducible but may hint to a clue) when I tried the same steps in my actual project, this last answer worked, but then I got an error saying libgnustl_shared.so
instead of libjsc.so
.
Describe what you expected to happen:
I expected a fresh package to run normally with 0.60.
How can I get React Native 0.60 working with Android?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:26
- Comments:39 (2 by maintainers)
Found a fix, this works for me (based off of the suggestion over at #25537):
Do an
Then make sure to add this jsc-android block to your
android/build.gradle
:If you already have this block in your
android/build.gradle
make sure$rootDir/../node_modules/jsc-android/dist
is a valid path in your project. If not, make sure you do thenpm install --save jsc-android
Note: This fixes the crash caused by
libjsc.so
, but the error aboutNo implementation found for com.facebook.react.bridge.Inspector
is still being logged. It’s being tracked at #25560@dulmandakh Please reconsider reopening this issue, as I’ve said I’m not using any third party modules, and many other people here are having the same problem with me.