谷歌中国开发者社区 (GDG)
  • 主页
  • 博客
    • Android
    • Design
    • GoogleCloud
    • GoogleMaps
    • GooglePlay
    • Web
  • 社区
    • 各地社区
    • 社区历史
    • GDG介绍
    • 社区通知
  • 视频
  • 资源
    • 资源汇总
    • 精选视频
    • 优酷频道

Introducing Android Native Development Kit r14

2017-03-22adminAndroidNo comments
Posted by Dan Albert, Android NDK Tech Lead


Android NDK r14

The latest version of the Android Native Development Kit (NDK), Android NDK r14,
is now available for download. It
is also available in the SDK manager via Android Studio.

So what’s new in r14? The full changelog can be seen here, but the
highlights include the following:

  • Updated all the platform headers to unified headers (covered in detail
    below)
  • LTO with Clang now works on Darwin and Linux
  • libc++ has been updated. You can now use thread_local for statics with
    non-trivial destructors (Clang only)
  • RenderScript is back!


    Unified Headers

    We’ve completely redone how we ship platform header files in the NDK. Rather
    than having one set of headers for every target API level, there’s now a single
    set of headers. The availability of APIs for each Android platform is guarded in
    these headers by #if __ANDROID_API__ >= __ANDROID_API_FOO__ preprocessor
    directives.

    The prior approach relied on periodically-captured snapshots of the platform
    headers. This meant that any time we fixed a header-only bug, the fix was only
    available in the latest version aside from the occasional backport. Now bugfixes
    are available regardless of your NDK API level.

    Aside from bugfixes, this also means you’ll have access to modern Linux UAPI
    headers at every target version. This will mostly be important for people
    porting existing Linux code (especially low-level things). Something important
    to keep in mind: just because you have the headers doesn’t mean you’re running
    on a device with a kernel new enough to support every syscall. As always with
    syscalls, ENOSYS is a possibility.

    Beyond the Linux headers, you’ll also have modern headers for OpenGL, OpenSLES,
    etc. This should make it easier to conditionally use new APIs when you have an
    older target API level. The GLES3 headers are now accessible on Ice Cream
    Sandwich even though that library wasn’t available until KitKat. You will still
    need to use all the API calls via dlopen/dlsym, but you’ll at least have
    access to all the constants and #defines that you would need for invoking
    those functions.

    Note that we’ll be removing the old headers from the NDK with r16, so the sooner
    you file bugs, the smoother the transition will go.


    Caveats

    The API #ifdef guards do not exist in third-party headers like those found in
    OpenGL. In those cases you’ll receive a link time error (undefined reference)
    rather than a compile time error if you use an API that is not available in your
    targeted API level.

    Standalone toolchains using GCC are not supported out of the box (nor will they
    be). To use GCC, pass -D__ANDROID_API__=$API when compiling.


    Enabling Unified Headers in Your Build

    To ease the transition from the legacy headers to the unified headers, we
    haven’t enabled the new headers by default, though we’ll be doing this in r15.
    How you opt-in to unified headers will depend on your build system.

    ndk-build

    In your Application.mk:

        APP_UNIFIED_HEADERS := true
    

    You can also set this property from the command-line like this:

        $ ndk-build APP_UNIFIED_HEADERS=true
    

    If you’re using ndk-build via Gradle with externalNativeBuild, specify the
    following configuration settings in build.gradle:

        android {
          ...
          defaultConfig {
            ...
            externalNativeBuild {
              ndkBuild {
                ...
                arguments "APP_UNIFIED_HEADERS=true"
              }
            }
          }
        }
    


    CMake

    When configuring your build, set ANDROID_UNIFIED_HEADERS=ON. This will usually
    take the form of invoking CMake with cmake -DANDROID_UNIFIED_HEADERS=ON
    $OTHER_ARGS
    .

    If you’re using CMake via Gradle with externalNativeBuild, you can use:

        android {
          ...
          defaultConfig {
            ...
            externalNativeBuild {
              cmake {
                ...
                arguments "-DANDROID_UNIFIED_HEADERS=ON"
              }
            }
          }
        }
    


    Standalone Toolchains

    When creating your standalone toolchain, pass –unified-headers. Note that
    this option is not currently available in the legacy script, make-standalone-toolchain.sh, but only in make_standalone_toolchain.py.


    Experimental Gradle Plugin

    Coming soon! Follow along here.


    Custom Build System?

    We’ve got you covered. Instructions on adding support for unified headers to
    your build system can be found here.

    For additional information about unified headers, see our docs and the tracking bug. If you’re looking ahead to future releases, the most up-to-date version of the
    documentation is in the master branch.



Source: Introducing Android Native Development Kit r14

除非特别声明,此文章内容采用知识共享署名 3.0许可,代码示例采用Apache 2.0许可。更多细节请查看我们的服务条款。

Tags: Android

Related Articles

A New Universal Music Player

2018-06-30admin

5 tips for building communities on mobile

2017-03-28admin

Meet the 20 finalists of the Google Play Indie Games Contest

2017-01-16admin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Recent Posts

  • Admin Essentials: know your options for Modern Enterprise Browser Management
  • TheVentureCity and Google Consolidate Miami as a Tech Powerhouse
  • Keep a better eye on your Google Cloud environment
  • Using HLL++ to speed up count-distinct in massive datasets
  • Season of Docs Announces Results of 2019 Program

Recent Comments

  • admin on Using advanced Kubernetes autoscaling with Vertical Pod Autoscaler and Node Auto Provisioning
  • Martijn on Using advanced Kubernetes autoscaling with Vertical Pod Autoscaler and Node Auto Provisioning
  • Martijn on Using advanced Kubernetes autoscaling with Vertical Pod Autoscaler and Node Auto Provisioning
  • Chen Zhixiang on Concurrent marking in V8
  • admin on 使用 Android Jetpack 加快应用开发速度

Archives

  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • January 1970

Categories

  • Android
  • Design
  • Firebase
  • GoogleCloud
  • GoogleDevFeeds
  • GoogleMaps
  • GooglePlay
  • Google动态
  • iOS
  • Uncategorized
  • VR
  • Web
  • WebMaster
  • 社区
  • 通知

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

最新文章

  • Admin Essentials: know your options for Modern Enterprise Browser Management
  • TheVentureCity and Google Consolidate Miami as a Tech Powerhouse
  • Keep a better eye on your Google Cloud environment
  • Using HLL++ to speed up count-distinct in massive datasets
  • Season of Docs Announces Results of 2019 Program
  • Admin Insider: What's new in Chrome Enterprise, Release 79
  • Discover insights from text with AutoML Natural Language, now generally available
  • Introducing Storage Transfer Service for on-premises data
  • How Mynd uses G Suite to manage a flurry of acquisitions
  • W3C Trace Context Specification: What it Means for You

最多查看

  • 如何选择 compileSdkVersion, minSdkVersion 和 targetSdkVersion (25,381)
  • Google 推出的 31 套在线课程 (22,461)
  • 谷歌招聘软件工程师 (22,337)
  • Seti UI 主题: 让你编辑器焕然一新 (13,824)
  • Android Studio 2.0 稳定版 (9,420)
  • Android N 最初预览版:开发者 API 和工具 (8,036)
  • 像 Sublime Text 一样使用 Chrome DevTools (6,325)
  • 用 Google Cloud 打造你的私有免费 Git 仓库 (6,077)
  • Google I/O 2016: Android 演讲视频汇总 (5,609)
  • 面向普通开发者的机器学习应用方案 (5,539)
  • 生还是死?Android 进程优先级详解 (5,233)
  • 面向 Web 开发者的 Sublime Text 插件 (4,341)
  • 适配 Android N 多窗口特性的 5 个要诀 (4,311)
  • 参加 Google I/O Extended,观看 I/O 直播,线下聚会! (3,624)
© 2019 中国谷歌开发者社区 - ChinaGDG