使用Android Studio內建的NDK編譯JNI

來源:互聯網
上載者:User

標籤:undefined   www   c++   war   span   print   ken   app   missing   

/********************************************************************************** *                      使用Android Studio內建的NDK編譯JNI * 說明: *     省得自己另外去下載NDK,編譯JNI,麻煩。 *               *                                          2017-4-30 深圳 龍華民治樟坑村 曾劍鋒 *********************************************************************************/一、參考文檔:    1. NDK環境搭建-windows篇        http://www.jianshu.com/p/708e6bf68ae9    2. Mistake in documentation/error message?        https://github.com/android-ndk/ndk/issues/264    3. 編譯一個模組時出現undefined reference to `__android_log_print‘         http://bbs.csdn.net/topics/360020076二、error:    1. 錯誤1:        1. 錯誤現象:            D:\zengjf\SourceCode\Android\android_app\Test>ndk-build            C:/Users/zengjf/AppData/Local/Android/Sdk/ndk-bundle/build//../build/core/build-binary.mk:687: Android NDK: Module zengjf depends on undefined modules: android_runtime nativehelper cutils utils log            C:/Users/zengjf/AppData/Local/Android/Sdk/ndk-bundle/build//../build/core/build-binary.mk:701: *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies)    .  Stop.            D:\zengjf\SourceCode\Android\android_app\Test>        2. 解決方案            1. C:\Users\zengjf\AppData\Local\Android\Sdk\ndk-bundle\build\core\build-binary.mk            2. 修改內容:                ...                ifdef undefined_libs                    $(call __ndk_warning,Module $(LOCAL_MODULE) depends on undefined modules: $(undefined_libs))                    # https://github.com/android-ndk/ndk/issues/208                    # ndk-build didn‘t used to fail the build for a missing dependency. This                    # seems to have always been the behavior, so there‘s a good chance that                    # there are builds out there that depend on this behavior (as of right now,                    # anything using libc++ on ARM has this problem because of libunwind).                    #                    # By default we will abort in this situation because this is so completely                    # broken. A user may define APP_ALLOW_MISSING_DEPS to "true" in their                    # Application.mk or on the command line to revert to the old, broken                    # behavior.                    APP_ALLOW_MISSING_DEPS=true    // add this line                     ifneq ($(APP_ALLOW_MISSING_DEPS),true)                        $(call __ndk_error,Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies))                    endif                endif                ...    2. 錯誤2:        1. 錯誤現象:            undefined references to `__android_log_print‘ follow        2. 解決方案:            Android.mk檔案中加入LOCAL_LDLIBS += -llog即可

 

使用Android Studio內建的NDK編譯JNI

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.