react-native: App build has warning issues "Unable to strip the following libraries"

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® Core™ 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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (2 by maintainers)

Most upvoted comments

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.

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.

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

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

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'
    }
}

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.