question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fresh Install Android Broken on React Native 0.60 RC2

See original GitHub issue

As 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

  1. Create a new React Native Project react-native init testproject (it creates a project using "react-native": "0.59.9" dependency).
  2. Make sure your emulator is running. Try to run cd /Users/Can/Desktop/testproject && react-native run-android (replace path with yours).
  3. In my case it couldn’t find the Android SDK, so I added local.properties into android folder with the content sdk.dir=/Users/Can/Library/Android/sdk (replace it with your Android SDK path)
  4. Run react-native run-android again. It runs perfectly. It displays the default Hello World app screen on my emulator.
  5. Open package.json and switch RN version to 0.60 RC2: "react-native": "0.60.0-rc.2"
  6. Run npm install to update to latest version.
  7. Try running react-native run-android again. It errors Task :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" to application tag in my project’s root AndroidManifest.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:closed
  • Created 4 years ago
  • Reactions:26
  • Comments:39 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
chrisspankroycommented, Jul 9, 2019

Found a fix, this works for me (based off of the suggestion over at #25537):

Do an

npm install --save jsc-android

Then make sure to add this jsc-android block to your android/build.gradle:

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }

        //THIS ONE
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
    }
}

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 the npm install --save jsc-android

Note: This fixes the crash caused by libjsc.so, but the error about No implementation found for com.facebook.react.bridge.Inspector is still being logged. It’s being tracked at #25560

16reactions
canpoyrazoglucommented, Jul 6, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting library "libjsc.so" not found after upgrading React ...
Here is my fix for this I was facing this issue, in my case Hermes was needed so, I managed to fix this...
Read more >
react-native run-android failed to launch emulator - You.com
1. Click AVD Manager from Android Studio. 2. Click Create Virtual Device 3. Select your device from device list and click Next 4....
Read more >
Installation - React Native Elements
If your project is a standard React Native project created using react-native init (it should have an ios/android directory), then you need to...
Read more >
Troubleshooting - React Native
You will also need to update your applications to load the JavaScript bundle from the new port. If running on device from Xcode, ......
Read more >
React Native 0.60 Add Reactnativefbsdk Module - ADocLib
Index Php Fresh Install Android Broken On React Native 0 60 Rc2 Issue 25415 Facebook React Native Github Fresh Install Android Broken On...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found