Home | History | Annotate | Download | only in config
      1 <html devsite>
      2   <head>
      3     <title>Namespaces for Native Libraries</title>
      4     <meta name="project_path" value="/_project.yaml" />
      5     <meta name="book_path" value="/_book.yaml" />
      6   </head>
      7   <body>
      8   <!--
      9       Copyright 2017 The Android Open Source Project
     10 
     11       Licensed under the Apache License, Version 2.0 (the "License");
     12       you may not use this file except in compliance with the License.
     13       You may obtain a copy of the License at
     14 
     15           http://www.apache.org/licenses/LICENSE-2.0
     16 
     17       Unless required by applicable law or agreed to in writing, software
     18       distributed under the License is distributed on an "AS IS" BASIS,
     19       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     20       See the License for the specific language governing permissions and
     21       limitations under the License.
     22   -->
     23 
     24 
     25 
     26 <p>
     27 Android 7.0 introduced namespaces for native libraries to limit internal API
     28 visibility and resolve situations when apps accidentally end up using platform
     29 libraries instead of their own. See the <a
     30 href="http://android-developers.blogspot.com/2016/06/improving-stability-with-private-cc.html">Improving
     31 Stability with Private C/C++ Symbol Restrictions in Android 7.0</a> Android
     32 Developers blog post for application-specific changes.</p>
     33 
     34 <h2 id="architecture">Architecture</h2>
     35 
     36 <p>
     37 The change separates system libraries from application libraries and makes it
     38 hard to use internal system libraries by accident (and vice versa).
     39 </p>
     40 
     41 <img src="images/namespace-libraries.png" alt="Namespaces for native libraries" id="namespace-libraries" />
     42 <p class="img-caption">
     43   <strong>Figure 1.</strong> Namespaces for native libraries
     44 </p>
     45 
     46 <p>
     47 Namespaces for native libraries prevent apps from using private-platform native
     48 APIs (as was done with OpenSSL). It also removes situations where apps
     49 accidentally end up using platform libraries instead of their own (as witnessed
     50 with <code>libpng</code>).
     51 </p>
     52 
     53 <h2 id="adding-additional-native-libraries">Adding additional native
     54 libraries</h2>
     55 
     56 <p>
     57 In addition to standard public native libraries, vendors may choose to provide
     58 additional native libraries accessible to apps by putting them under the
     59 <code>/vendor</code> library folder (/vendor/lib for 32 bit libraries and,
     60 /vendor/lib64 for 64 bit) and listing them in:
     61 <code>/vendor/etc/public.libraries.txt</code>
     62 </p>
     63 
     64 <h2 id="updating-app-non-public">Updating apps to not use non-public native libraries</h2>
     65 
     66 <p>
     67 This feature is enabled only for applications targeting SDK version 24 or later;
     68 for backward compatibility, see <a
     69 href="http://android-developers.blogspot.com/2016/06/improving-stability-with-private-cc.html">Table
     70 1. What to expect if your app is linking against private native libraries</a>.
     71 The list of Android native libraries accessible to apps (also know as
     72 public native libraries) is listed in CDD section 3.1.1.  Apps targeting 24 or
     73 later and using any non-public libraries should be updated. Please see <a
     74 href="https://developer.android.com/preview/behavior-changes.html#ndk">NDK Apps
     75 Linking to Platform Libraries </a> for more details.
     76 </p>
     77 
     78   </body>
     79 </html>
     80