Android7.0 Post-JNI libraries prohibit access to private APIs

Source: Internet
Author: User

This modification is described in the Google website as follows:

Private API (Enforced since API 24)

Native libraries must use only public APIs, and must not link against NON-NDK platform libraries. Starting with API the this rule was enforced and applications is no longer able to load NON-NDK platform libraries. The rule is enforced by the dynamic linker, so non-public libraries was not accessible regardless of the the the-the-same-code tries to Load Them:System.loadLibrary (...), dt_needed entries, and direct calls to Dlopen (...) would fail in exactly the same.

Users should has a consistent app experience across updates, and developers shouldn ' t has to make emergency app Updat ES to handle platform changes. For that reason, we recommend against using the private C + + symbols. Private symbols aren ' t tested as part of the compatibility Test Suite (CTS) That's all Android devices must pass. They may not be exist, or they may behave differently. This makes apps the use them more likely to fail on specific devices, or on the future releases---as many developers found When Android 6.0 Marshmallow switched from OpenSSL to Boringssl.

In order to reduce the user impact of this transition, we ' ve identified a set of libraries. See significant use fro M Google Play ' s most-installed apps, and that is feasible for us-to-support in the short term (including Libandroid_runti Me.so, libcutils.so, libcrypto.so, and libssl.so). In order to give your more time to transition, we'll temporarily support these libraries; So if you see a warning that means your code would not work in a future release – please fix it now!

$ readelf--dynamic libbroken.so | grep NEEDED 0x00000001 (NEEDED)                     shared library: [libnativehelper.so] 0x00000001 (NEEDED)                     shared library: [ Libutils.so] 0x00000001 (NEEDED)                     shared library: [libstagefright_foundation.so] 0x00000001 (NEEDED)                     shared Library: [libmedia_jni.so] 0x00000001 (NEEDED)                     shared library: [liblog.so] 0x00000001 (NEEDED)                     shared library: [Libdl.so] 0x00000001 (NEEDED)                     shared library: [libz.so] 0x00000001 (NEEDED)                     shared library: [libstdc++.so] 0x00000001 (NEEDED)                     shared library: [libm.so] 0x00000001 (NEEDED)                     shared library: [libc.so]

Potential problems:starting from API the dynamic linker would not load private libraries, preventing the application FR Om Loading.

Resolution:rewrite your native code to rely only on the public API. As a short term workaround, platform libraries without complex dependencies (libcutils.so) can is copied to the project. As a long term solution the relevant code must is copied to the project tree. Ssl/media/jni Internal/binder APIs should not being accessed from the native code. When necessary, native code should call appropriate public Java API methods.

A complete list of publicly libraries is available within the NDK, under platforms/android-API/usr/lib .

Note:ssl/crypto is a special case, applications must not use platform Libcrypto and LIBSSL libraries directly, even on OL Der Platforms. All applications should use GMS Security Provider to ensure they is protected from known vulnerabilities.

Android7.0 Post-JNI libraries prohibit access to private APIs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.