android ndk(一) hello-jni

1.下載ndk-r7b,因爲r7以及之後的版本繼承了cygwin,(make gcc), 所以下載解壓後就算環境配置好了,最好也下個CDT重啓安裝,以方便在Eclipse裏對c代碼的編寫

2.入門 導入hello-jni , 本人很懶就直接複製官網的了,相信都看的懂

Click File > New Android Project...

Select the Create project from existing source radio button.

Select any API level above Android 1.5.

In the Location field, click Browse... and select the <ndk-root>/samples/hello-jni directory.

Click Finish.  

3.編譯builder

官網提供的文檔沒看懂,這裏用其他的方法

 (1)項目上點右鍵properties->builders->new  Locatioin 配置ndk-build.cmd的路徑,Working Directory選擇要編譯的項目

(2)打鉤refresh的refresh resources upon completion


(3)打鉤build options 的During auto builds 和specify working set of relevant resources


(4)點擊specify resources打鉤jni文件夾.這樣勾是告訴builder,只編譯這個文件夾的文件即可.整個項目編譯的話,電腦會嚎叫的


(5)控制檯打印信息,項目裏有了libs/armeabi/libhello-jni.so和obj文件夾


4.運行程序,顯示出了結果,你可以喝點銀鷺慶賀哦


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章