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