Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
leonidlewis opened this issue Jan 8, 2022 · 10 comments
Open

Comments

@leonidlewis
Copy link

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
Copy link

vassbg commented Jan 18, 2022

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

clytras commented Jul 28, 2022

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"
        }
    }
}
  1. 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
Copy link

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
Copy link

chirag-codealchemy commented Mar 31, 2023

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
Copy link

Same issue here

@iTheDaybreak
Copy link

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

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

No branches or pull requests