標籤:android blog http get 檔案 os
下載並解壓安卓SDK(帶Eclipse)和NDK
運行Eclipse
選擇菜單ADT->Preferences->Android->NDK->Browse
選擇之前解壓的NDK目錄
點擊OK
右鍵Package Exploder空白處->Import->Android->Existing Android Code Into Workspace
點擊Next
點擊Browse
選擇cocos2d的Android樣本項目
右鍵Package Explorer裡的SimpleGame->Properties->C/C++ Build->Tool Chain Editor
Display compatible toolchains only:不選
Current toolchain:Android GCC
Current builder:Android Builer
點擊C/C++ Build
Build command:添加 NDK_DEBUG=1
Generate MakeFiles automatically:不勾選
Bulid directory:${ProjDirPath}
拷貝cocos2d-2.1rc0-x-2.1.3下cocos2dx、CocosDenshion、extensions、external四個檔案夾到android-ndk-r8e/sources
拷貝cocos2d-2.1rc0-x-2.1.3/cocos2dx/platform/third_party/android/prebuilt下所有檔案夾到android-ndk-r8e/sources
解壓libiconv.zip到android-ndk-r8e/sources
注:
0:
命令列 vim ~ /.bash_profile
添加兩行export NDK_ROOT=/Users/Apple/Documents/android-ndk-r8e
export PATH=${PATH}:${NDK_ROOT}
echo命令驗證環境變數有沒有設定成功
1:
發現這個bug是通過clean cocos2d-x項目時出現的,錯誤資訊為make: *** [clean-box2d_staticarmeabi] Error 2
而正常build不會出任何問題,問題是由於r8e版的NDK中的build/core/build-binary.mk一處錯誤導致。
替換49行的:
$(cleantarget): PRIVATE_CLEAN_FILES := ($(my)OBJS)
為:
$(cleantarget): PRIVATE_CLEAN_FILES := $($(my)OBJS)
即可。
另外,參考文章中還提到,對於64bit Mac版的NDK的另外一個問題,修正如下,一塊改了以絕後患:
${ANDROID_NDK}/ndk-build: 第158行:
file -L “$SHELL” | grep -q “x86[_-]64″
替換為:
file -L “$SHELL” | grep -q “[xX]86[_-]64″
${ANDROID_NDK}/build/core/init.mk: 第229行:
ifneq (,$(shell file -L $(SHELL) | grep ‘x86[_-]64′))
替換為:
ifneq (,$(shell file -L $(SHELL) | grep ‘[xX]86[_-]64′))
2:
右鍵Package Explorer裡的SimpleGame->Android Tools->Add Support Library
3:
Window->Customize Perspective->Command Groups Availability
Android SDK and AVD Manager 勾選
Window->Android SDK Manager
安裝Android 2.2(API 8)、Android SDK Build-Tools 18,1,1
卸載
4:
離線安裝:http://www.eoeandroid.com/thread-226410-1-1.html