facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.46k stars 24.25k forks source link

App build has warning issues "Unable to strip the following libraries" #32857

Closed leonidlewis closed 3 months ago

leonidlewis commented 2 years ago

Description

When I build the simple app only shows "Hello world", I've got the following warning, and the size of my app reaches 32MB. I used the build command ./gradlew assembleRelease and also used Android Studio. I got the same warning in both cases. Android Studio has installed the NDK(side by side) to strip these packages. How can I fix this issue?

> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as 
they are: libbetter.so, libc++_shared.so, libevent-2.1.so,

Version

0.66.4

Output of npx react-native info

info Fetching system and libraries information... System: OS: Windows 10 10.0.18362 CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz Memory: 1.97 GB / 11.85 GB Binaries: Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Version 4.2.0.0 AI-202.7660.26.42.7351085 Visual Studio: Not Found Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.4 => 0.66.4 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

I created the app with this command. npx react-native init sample I installed react-native-geolocation-service. I build the app with ./gradlew assembleRelease But I've got a warning.

Snack, code example, screenshot, or link to a repository

No response

vassbg commented 2 years ago

Hi, I have that warning too, and I am uncertain if I should be worried or not. I gives that warning on a the initial app with nothing else in it - just:

npx react-native init Test cd Test npx react-native run-android

Works fast and opens the app but gives that warning:

Task :app:stripDebugDebugSymbols Unable to strip the following libraries, packaging them as they are: libbetter.so, libc++_shared.so, libevent-2.1.so, libevent_core-2.1.so, libevent_extra-2.1.so, libfabricjni.so, libfb.so, libfbjni.so, libflipper.so, libfolly_futures.so, libfolly_json.so, libglog.so, libglog_init.so, libhermes-executor-common-debug.so, libhermes-executor-common-release.so, libhermes-executor-debug.so, libhermes-executor-release.so, libhermes-inspector.so, libimagepipeline.so, libjsc.so, libjscexecutor.so, libjsi.so, libjsijniprofiler.so, libjsinspector.so, liblogger.so, libmapbufferjni.so, libnative-filters.so, libnative-imagetranscoder.so, libreact_codegen_rncore.so, libreact_debug.so, libreact_nativemodule_core.so, libreact_render_animations.so, libreact_render_attributedstring.so, libreact_render_componentregistry.so, libreact_render_core.so, libreact_render_debug.so, libreact_render_graphics.so, libreact_render_imagemanager.so, libreact_render_leakchecker.so, libreact_render_mapbuffer.so, libreact_render_mounting.so, libreact_render_runtimescheduler.so, libreact_render_scheduler.so, libreact_render_telemetry.so, libreact_render_templateprocessor.so, libreact_render_textlayoutmanager.so, libreact_render_uimanager.so, libreact_utils.so, libreactconfig.so, libreactnativeblob.so, libreactnativejni.so, libreactnativeutilsjni.so, libreactperfloggerjni.so, librrc_image.so, librrc_modal.so, librrc_progressbar.so, librrc_root.so, librrc_scrollview.so, librrc_slider.so, librrc_switch.so, librrc_text.so, librrc_textinput.so, librrc_unimplementedview.so, librrc_view.so, libturbomodulejsijni.so, libyoga.so.

My react-native info is:

System: OS: Windows 10 10.0.22000 CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz Memory: 2.37 GB / 7.81 GB Binaries: Node: 16.13.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 29, 30, 31, 32 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0 System Images: android-29 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7935034 Visual Studio: Not Found Languages: Java: 1.8.0_312 - C:\Program Files\OpenJDK\openjdk-8u312-b07\bin\javac.EXE npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.4 => 0.66.4 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

thejadasari commented 2 years ago

If you are using Gradle build tools version 4 or higher, adding android:extractNativeLibs="true" to application as per android documentation, may solve the issue.

https://developer.android.com/studio/releases/gradle-plugin#extractNativeLibs

mathews-p commented 2 years ago

If you are using Gradle build tools version 4 or higher, adding android:extractNativeLibs="true" to application as per android documentation, may solve the issue.

https://developer.android.com/studio/releases/gradle-plugin#extractNativeLibs

@thejadasari This will not resolve the "Unable to strip the libraries error". This will help to reduce the build apk size.

quentingirard commented 2 years ago

I'm on an existing app and I have the same issue when I migrated from react-native 0.64 to 0.67.3.

Unable to strip the following libraries, packaging them as they are: libbetter.so, libc++_shared.so, libconceal.so, libevent-2.1.so, libevent_core-2.1.so, libevent_extra-2.1.so, libfabricjni.so, libfb.so, libfbjni.so, libflipper.so, libfolly_futures.so, libfolly_json.so, libglog.so, libglog_init.so, libhermes-executor-common-debug.so, libhermes-executor-debug.so, libhermes-inspector.so, libhermes.so, libimagepipeline.so, libjsi.so, libjsijniprofiler.so, libjsinspector.so, liblogger.so, libmapbufferjni.so, libnative-filters.so, libnative-imagetranscoder.so, libreact_codegen_rncore.so, libreact_debug.so, libreact_nativemodule_core.so, libreact_render_animations.so, libreact_render_attributedstring.so, libreact_render_componentregistry.so, libreact_render_core.so, libreact_render_debug.so, libreact_render_graphics.so, libreact_render_imagemanager.so, libreact_render_leakchecker.so, libreact_render_mapbuffer.so, libreact_render_mounting.so, libreact_render_runtimescheduler.so, libreact_render_scheduler.so, libreact_render_telemetry.so, libreact_render_templateprocessor.so, libreact_render_textlayoutmanager.so, libreact_render_uimanager.so, libreact_utils.so, libreactconfig.so, libreactnativeblob.so, libreactnativejni.so, libreactnativeutilsjni.so, libreactperfloggerjni.so, libreanimated.so, librrc_image.so, librrc_modal.so, librrc_progressbar.so, librrc_root.so, librrc_scrollview.so, librrc_slider.so, librrc_switch.so, librrc_text.so, librrc_textinput.so, librrc_unimplementedview.so, librrc_view.so, libturbomodulejsijni.so, libyoga.so.

In addition, I'm trying to migrate to hermes engine (following: https://reactnative.dev/docs/hermes) and the const isHermes = () => !!global.HermesInternal return false.

I guess it's related to libhermes-executor-common-debug.so, libhermes-executor-debug.so, libhermes-inspector.so, libhermes.so.

elliotmrodriguez commented 2 years ago

Same predicament, been struggling mightily with this for a week. Our libs would not be stripped and caused an oversized base.zip file in our build files (800 mb!), which causes node to choke.

What has mostly helped is adding the ndk.dir property to local.properties and pointing it to ndk-bundle directory. Although you will see deprecation (of ndk.dir) warnings, that resolved this mostly; we still have one library that isn't stripped (libconceal.so).

clytras commented 2 years ago

The NDK version set by ndkVersion inside android/build.gradle must be installed using Android Studio SDK Tools.

  1. Check the ndkVersion inside android/build.gradle

    buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
    
        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    }
  2. Open Android Studio 🡪 Settings 🡪 Android SDK 🡪 SDK Tools, check the "Show Package Details" at bottom right and then under NDK (Side by side) check the exact version to match the one inside android/build.gradle and then hit the Apply button. android studio - sdk tools

Wait to finish installing and then clean the app with something like cd android && ./gradlew clean && cd .. and then rebuild it.

This fixed this issue for me and there are no "Unable to strip the following libraries" errors any more after clean builds.

vedant-sp1 commented 1 year ago

I'm still getting this issue after after following the NDK steps I'm using M1 device do I have to add any NDK path or any thing else ?

chirag-codealchemy commented 1 year ago

libbetter.so, libc++_shared.so, libconceal.so, libevent-2.1.so, libevent_core-2.1.so, libevent_extra-2.1.so, libfabricjni.so, libfb.so, libfbjni.so, libflipper.so, libfolly_futures.so, libfolly_json.so, libglog.so, libglog_init.so, libhermes-executor-common-debug

add this to your app build gradle

android {
    packagingOptions {
        pickFirst 'lib/*/*.so'
    }
}
shakibhasan09 commented 10 months ago

Same issue here

iTheDaybreak commented 9 months ago

用命令--info 查看原因,一般是ndkVersion 不匹配,strip tools找不到 bash gradlew assembleRelease --info

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

cortinico commented 3 months ago

Closing as extremely old issue. The NDK integration of RN has been completely rewritten as of 0.71 so this issue is definitely not relevant anymore

clytras commented 3 months ago

RN 0.74

> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libc++_shared.so, libfabricjni.so, libfbjni.so, libfolly_runtime.so, libglog.so, libhermes.so, libhermes_executor.so, libhermesinstancejni.so, libimagepipeline.so, libjscinstance.so, libjsi.so, libjsijniprofiler.so, libjsinspector.so, libmapbufferjni.so, libnative-filters.so, libnative-imagetranscoder.so, libreact_codegen_rncore.so, libreact_cxxreactpackage.so, libreact_debug.so, libreact_devsupportjni.so, libreact_featureflags.so, libreact_featureflagsjni.so, libreact_nativemodule_core.so, libreact_newarchdefaults.so, libreact_render_componentregistry.so, libreact_render_core.so, libreact_render_debug.so, libreact_render_element.so, libreact_render_graphics.so, libreact_render_imagemanager.so, libreact_render_mapbuffer.so, libreact_utils.so, libreactnativeblob.so, libreactnativejni.so, libreactperfloggerjni.so, librninstance.so, librrc_image.so, librrc_legacyviewmanagerinterop.so, librrc_view.so, libruntimeexecutor.so, libturbomodulejsijni.so, libuimanagerjni.so, libyoga.so.

This is after a fresh new project using npx @react-native-community/cli@latest init RNTest, after running a gradlew clean and then yarn run-android.

@cortinico As you can see, closing an issue saying that it's old and now not relevant does not magically solve the problem. Please consider reopening this issue.

cortinico commented 3 months ago

RN 0.74

> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libc++_shared.so, libfabricjni.so, libfbjni.so, libfolly_runtime.so, libglog.so, libhermes.so, libhermes_executor.so, libhermesinstancejni.so, libimagepipeline.so, libjscinstance.so, libjsi.so, libjsijniprofiler.so, libjsinspector.so, libmapbufferjni.so, libnative-filters.so, libnative-imagetranscoder.so, libreact_codegen_rncore.so, libreact_cxxreactpackage.so, libreact_debug.so, libreact_devsupportjni.so, libreact_featureflags.so, libreact_featureflagsjni.so, libreact_nativemodule_core.so, libreact_newarchdefaults.so, libreact_render_componentregistry.so, libreact_render_core.so, libreact_render_debug.so, libreact_render_element.so, libreact_render_graphics.so, libreact_render_imagemanager.so, libreact_render_mapbuffer.so, libreact_utils.so, libreactnativeblob.so, libreactnativejni.so, libreactperfloggerjni.so, librninstance.so, librrc_image.so, librrc_legacyviewmanagerinterop.so, librrc_view.so, libruntimeexecutor.so, libturbomodulejsijni.so, libuimanagerjni.so, libyoga.so.

This is after a fresh new project using npx @react-native-community/cli@latest init RNTest, after running a gradlew clean and then yarn run-android.

@cortinico As you can see, closing an issue saying that it's old and now not relevant does not magically solve the problem. Please consider reopening this issue.

Feel free to open a new issue, by providing your full build log.

clytras commented 3 months ago

RN 0.74

> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libc++_shared.so, libfabricjni.so, libfbjni.so, libfolly_runtime.so, libglog.so, libhermes.so, libhermes_executor.so, libhermesinstancejni.so, libimagepipeline.so, libjscinstance.so, libjsi.so, libjsijniprofiler.so, libjsinspector.so, libmapbufferjni.so, libnative-filters.so, libnative-imagetranscoder.so, libreact_codegen_rncore.so, libreact_cxxreactpackage.so, libreact_debug.so, libreact_devsupportjni.so, libreact_featureflags.so, libreact_featureflagsjni.so, libreact_nativemodule_core.so, libreact_newarchdefaults.so, libreact_render_componentregistry.so, libreact_render_core.so, libreact_render_debug.so, libreact_render_element.so, libreact_render_graphics.so, libreact_render_imagemanager.so, libreact_render_mapbuffer.so, libreact_utils.so, libreactnativeblob.so, libreactnativejni.so, libreactperfloggerjni.so, librninstance.so, librrc_image.so, librrc_legacyviewmanagerinterop.so, librrc_view.so, libruntimeexecutor.so, libturbomodulejsijni.so, libuimanagerjni.so, libyoga.so.

This is after a fresh new project using npx @react-native-community/cli@latest init RNTest, after running a gradlew clean and then yarn run-android. @cortinico As you can see, closing an issue saying that it's old and now not relevant does not magically solve the problem. Please consider reopening this issue.

Feel free to open a new issue, by providing your full build log.

Like people don't have anything better to do and they just come back to issues and recreate them. No, I will not create an issue that was existing not resolved and closed blindly. If you don't care why should I.

bartlian commented 5 days ago

I have met this issue, but found the Android Emulator API was not correct. Then changed the version, it could be fine. Maybe this can help someone.