NDK環境搭建說明和NDK的調試–LOGI

來源:互聯網
上載者:User

NDK環境搭建說明。

1.下載cgywin並安裝。

  http://www.cygwin.com/
   注意事項:
   需要有 gcc / make / vim / patch
2.下載NDK for windows。
3.安裝配置NDK.
   修改cgywin的環境變數。
   c:\cgywin\home\user

 NDK=/cygdrive/E/dev/android-sdk/android_ndk_r5c
 export NDK
 PATH=$NDK:$PATH
 export PATH

4.驗證JNI的安裝情況。
   進入hellojni項目的jni目錄
  運行ndk-build。
  然後到libs下檢查.so
  打包APK到模擬器上運行hellojni。

NDK的調試--LOGI
為什麼需要LOGI?  JNI的程式調試的主要手段之一是列印,printf不知道列印到什麼地方去了。

LOGW不方便,見下面的URL    http://www.cnblogs.com/MarsGG/articles/2057433.html
 sprintf(szBuff....);
LOGW(szBuff....);

 

LOGI使用的時候很想printf,很方便,那麼如何支援LOGI?

Android.mk 中如下處理
ifeq ($(HOST_OS),windows)
#NDK環境下
    LOCAL_LDLIBS := -llog
else
#完整源碼環境下
    LOCAL_SHARED_LIBRARIES := libutils
endif

c 的代碼裡面這樣處理,在標頭檔中加入下面的宏。
#ifndef _NDK_BUILD_
    #include <utils/Log.h>
#else
    //#define LOGI printf
    #include <android/log.h>
    #define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) 
#endif

轉自http://blog.csdn.net/win2k3net/article/details/6618840

聯繫我們

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