Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Build Failed : More than one file was found with OS independent path 'lib/x86/libc++_shared.so' #54

Closed
c1ngular opened this issue Mar 21, 2019 · 20 comments

Comments

@c1ngular
Copy link

c1ngular commented Mar 21, 2019

Description

Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.

More than one file was found with OS independent path 'lib/x86/libc++_shared.so'

`
React Native Environment Info:
System:
OS: macOS 10.14.2
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 592.43 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash

Binaries:
  Node: 11.9.0 - /usr/local/bin/node
  npm: 6.9.0 - /usr/local/bin/npm
  Watchman: 4.9.0 - /usr/local/bin/watchman

SDKs:
  iOS SDK:
    Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1

  Android SDK:
    API Levels: 23, 25, 26, 27, 28
    Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 27.0.3, 28.0.3
    System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64

IDEs:
  Android Studio: 3.3 AI-182.5107.16.33.5314842
  Xcode: 10.1/10B61 - /usr/bin/xcodebuild

npmPackages:
  react: 16.8.3 => 16.8.3 
  react-native: 0.59.1 => 0.59.1 

npmGlobalPackages:
  react-native-cli: 2.0.1`

a totally new project , no other packages/plugin installed other than react-native-ffmpeg, no idea why, i remember it was working perfectly when i tried this project last time , is it related to react-native version ? and i assume there will be more such error other than "lib/x86/libc++_shared.so" ?

@c1ngular
Copy link
Author

c1ngular commented Mar 21, 2019

i added to build.gradle file :

packagingOptions {
    exclude 'lib/x86/libc++_shared.so'
    exclude 'lib/arm64-v8a/libc++_shared.so'
    exclude 'lib/x86_64/libc++_shared.so'        
    exclude 'lib/armeabi-v7a/libc++_shared.so'           
}

it builds , but app crashed on start up , android studio shows :

31839-31954/com.hlmp E/SoLoader: Error when loading lib: dlopen failed: library "libc++_shared.so" not found lib hash: 52bef5aa0fb455a23735042f417edc9a search path is /data/app/com.hlmp-vAWXk1fv9rTP7_wVw2LuNw==/lib/arm64

31839-31954/com.hlmp E/SoLoader: couldn't find DSO to load: libreactnativejni.so caused by: dlopen failed: library "libc++_shared.so" not found

31839-31954/com.hlmp E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.hlmp, PID: 31839
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: dlopen failed: library "libc++_shared.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.bridge.ReactBridge.staticInit(ReactBridge.java:31)
at com.facebook.react.bridge.NativeMap.(NativeMap.java:19)
at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:25)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:944)
at java.lang.Thread.run(Thread.java:764)

@c1ngular
Copy link
Author

c1ngular commented Mar 21, 2019

not sure if related , i was prompted by Android studio to update NDK version to 19.2.5345600, before that , i remember this package is working pretty well .

facebook/react-native#23764 (comment)

@c1ngular
Copy link
Author

c1ngular commented Mar 21, 2019

@tanersener
i tried to downgrade NDK to r18b version, not working
i tried to downgrade React Native version to 0.58.0 and 0.58.6 , problem seems resolved , it builds and runs , so i guess it is caused by RN ?

from change log of 0.59.0 :

Soloader is now at v0.6.0 (07d1075 by @dulmandakh)

is it related ?

@dulmandakh
Copy link

dulmandakh commented Mar 21, 2019 via email

@c1ngular
Copy link
Author

@dulmandakh thank you for help !

@tanersener
Copy link
Owner

I can safely say that it is not related to NDK version. It looks like something new in react-native is causing this as @dulmandakh pointed out. I need to perform some tests before confirming this.

@tanersener tanersener added enhancement New feature or request and removed needs-analysis labels Mar 21, 2019
@tanersener
Copy link
Owner

tanersener commented Mar 21, 2019

as @dulmandakh pointed out, libgnustl_shared.so is replaced with libc++_shared.so in react-native 0.59. react-native-ffmpeg already includes libc++_shared.so so using react-native 0.59 causes the More than one file was found with OS independent path 'lib/x86/libc++_shared.so' error.

@tanersener
Copy link
Owner

This issue will be fixed it in the next release which is planned to be published in the first week of April.

@c1ngular
Copy link
Author

c1ngular commented Apr 2, 2019

any update ?

@tanersener
Copy link
Owner

It looks like it won't be possible to remove libc++_shared.so library from the package.

So official workaround to use RN 0.59 is to add this block in build.gradle for Android.

packagingOptions {
    pickFirst 'lib/x86/libc++_shared.so'
    pickFirst 'lib/x86_64/libc++_shared.so'
    pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    pickFirst 'lib/arm64-v8a/libc++_shared.so'
}

@c1ngular
Copy link
Author

c1ngular commented Apr 3, 2019

@tanersener thanks

@c1ngular
Copy link
Author

c1ngular commented Apr 3, 2019

@tanersener it builds and runs , but it failed packaging with error below :

Task :react-native-ffmpeg:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-ffmpeg:verifyReleaseResources'.

java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/s1ngular/Projects/RNative/webvideo/node_modules/react-native-ffmpeg/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
/Users/s1ngular/Projects/RNative/webvideo/node_modules/react-native-ffmpeg/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
/Users/s1ngular/Projects/RNative/webvideo/node_modules/react-native-ffmpeg/android/build/intermediates/res/merged/release/values/values.xml:2724: error: resource android:attr/fontVariationSettings not found.
/Users/s1ngular/Projects/RNative/webvideo/node_modules/react-native-ffmpeg/android/build/intermediates/res/merged/release/values/values.xml:2725: error: resource android:attr/ttcIndex not found.
error: failed linking references.

@tanersener
Copy link
Owner

Can you share your package.json and build.gradle? So I can test your case locally?

@c1ngular
Copy link
Author

c1ngular commented Apr 3, 2019

package.json:

"dependencies": {
"i18n-js": "^3.2.1",
"lodash.memoize": "^4.1.2",
"react": "16.8.3",
"react-native": "0.59.1",
"react-native-ffmpeg": "^0.3.1",
"react-native-firebase": "^5.2.3",
"react-native-fs": "^2.13.3",
"react-native-keep-awake": "^4.0.0",
"react-native-localize": "^1.1.1",
"react-native-progress": "^3.6.0",
"react-native-safe-area-view": "^0.13.1",
"react-native-vector-icons": "^6.3.0",
"react-native-video": "^4.4.0",
"react-native-webview": "git+https://github.com/c1ngular/react-native-webview.git"
}

build.gradle:

buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.0.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

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

android->build.gradle:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
lintOptions {
disable 'MissingDefaultResource'
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

packagingOptions {
    pickFirst 'lib/x86/libc++_shared.so'
    pickFirst 'lib/x86_64/libc++_shared.so'
    pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    pickFirst 'lib/arm64-v8a/libc++_shared.so'       
}

defaultConfig {
    applicationId "com.lijiangsync.webvideo"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}    
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}

}

dependencies {
implementation project(':react-native-ffmpeg')
implementation project(':react-native-video')
implementation project(':react-native-vector-icons')
implementation project(':react-native-keep-awake')
implementation project(':react-native-webview')
implementation project(':react-native-fs')
implementation project(':react-native-localize')
implementation project(':react-native-firebase')
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation "com.google.firebase:firebase-ads:15.0.1"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}

task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

@c1ngular
Copy link
Author

c1ngular commented Apr 3, 2019

@tanersener

when i tried to build first time , it give two errors:

  1. android:allowBackup="true/false" conflict , i changed my AndroidManifest.xml , android:allowBackup=true
  2. minsdk version conflict ,i changed minSdkVersion from 16 to 21

besides the changes above , i added lintOption and packagingOption to build.gradle,
please take a look , thanks !

@tanersener
Copy link
Owner

Do you have AndroidX enabled in gradle.properties?

@c1ngular
Copy link
Author

c1ngular commented Apr 3, 2019

@tanersener no , just release keystore configurations , nothing more

@c1ngular
Copy link
Author

c1ngular commented Apr 3, 2019

@tanersener i was able to package after i changed compileSdkVersion and targetSdkVersion to 28 from ~/node_modules/react-native-ffmpeg/android/build.gradle

is this a good idea at all ?

@tanersener
Copy link
Owner

Well, editing files under ~/node_modules is not a good practice but today or tomorrow a new react-native-ffmpeg release will be published with compileSdkVersion and targetSdkVersion set to 28. So I can say it is OK temporarily.

@tanersener
Copy link
Owner

tanersener commented Apr 5, 2019

v0.3.2 is released and the fix for this issue is documented in the Tips section.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants