android studio ndk開發總結

來源:互聯網
上載者:User

標籤:函數   info   pre   關聯   androi   list   and   c語言   格式化   

1、path環境變數

2、android studio關聯ndk

     local.properties   ndk.dir

     gradle.properties  android.useDeprecatedNdk=true//相容老版本

3、build.gradle 配置 

    defaultConfig{

    ndk{

        moduleName "Hello"

        abiFilters ‘‘armeabi","armeabi-v7a","x86"

                    }

}

4、根據上層java 的native 函數,可自動產生 對應的標頭檔

   控台執行:javah -calsspath . 路徑檔案

5、使用android_log_print需要再編譯配置中加入log庫

如果你用的是正式版gradle,在ndk標籤中加入 ldLibs "log" 如果你用的是實驗版gradle,在ndk標籤中加入: ldLibs.add("log") 如果你使用CMakeLists,在target_link_libraries標籤中加入log如果你使用的是MK檔案,加入如下語句: LOCAL_LDLIBS := -llog 
//列印一個簡單Info層級的日誌 對應Java的Log.i("JNI","This is log")__android_log_print(ANDROID_LOG_INFO,"JNI","This is log"); //列印格式化字串 這裡使用的是C語言中printf中的格式。關於C中的printf格式化輸出可自行百度,文檔非常多。int i=5;__android_log_print(ANDROID_LOG_INFO,"JNI","i=%d",i); 

 

android studio ndk開發總結

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.