2017-06-06 122 views
2

我正在嘗試在我的MacOS Android Studio 2.3.2上構建AndEngine示例。 但是得到這個錯誤。無法弄清楚是什麼問題。奇怪的是,在同一版本的Android Studio上,通常在Windows上構建相同的項目。構建AndEngine的NDK時出錯示例

> FAILURE: Build failed with an exception. 
What went wrong: 
Execution failed for task ':andEngine:externalNativeBuildRelease'. 
> Build command failed. 
    Error while executing process /Users/apple/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/apple/Documents/workspace/AndroidStudio/AndEngineExamples-GLES2/andEngine/src/main/jni/Android.mk  

    NDK_APPLICATION_MK=/Users/apple/Documents/workspace/AndroidStudio/AndEngineExamples-GLES2/andEngine/src/main/jni/Application.mk APP_ABI=mips NDK_ALL_ABIS=mips NDK_DEBUG=0 APP_PLATFORM=android-9 NDK_OUT=/Users/apple/Documents/workspace/AndroidStudio/AndEngineExamples-GLES2/andEngine/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=/Users/apple/Documents/workspace/AndroidStudio/AndEngineExamples-GLES2/andEngine/build/intermediates/ndkBuild/release/lib /Users/apple/Documents/workspace/AndroidStudio/AndEngineExamples-GLES2/andEngine/build/intermediates/ndkBuild/release/obj/local/mips/libandengine.so} 
    Android NDK: android-9 is unsupported. Using minimum supported version android-14.  
    [mips] Compile++  : andengine_shared <= BufferUtils.cpp 
    /Users/apple/Documents/workspace/AndroidStudio/AndEngineExamples-GLES2/andEngine/src/main/jni/src/BufferUtils.cpp:13:2: error: use of undeclared identifier 'memcpy' 
      memcpy(bufferAddress, dataAddress + pOffset, pLength << 2); 
     ^

我Application.mk文件:

# Build both ARMv5TE and ARMv7-A and x86 machine code. 
APP_ABI := armeabi armeabi-v7a x86 
APP_STL := gnustl_shared 

而且Android.mk:

LOCAL_PATH:= $(call my-dir) 

include $(CLEAR_VARS) 

LOCAL_MODULE    := andengine_shared 
LOCAL_MODULE_FILENAME := libandengine 
LOCAL_CFLAGS    := -Werror 
LOCAL_SRC_FILES   := src/GLES20Fix.c \ 
          src/BufferUtils.cpp 
LOCAL_LDLIBS    := -lGLESv2 
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/src 

include $(BUILD_SHARED_LIBRARY) 
+0

正如您可能已經意識到的那樣,它無法找到'memcpy'的定義。你使用的是什麼NDK版本?給你Application.mk,你瞄準什麼設備? – yakobom

回答

1

的Android NDK:Android的9不受支持。使用最低支持版本 android-14。

Application.mk文件

添加APP_PLATFORM := android-14如果沒有該行那麼你的SDK版本從project.properties文件拍攝。

0

Android Studio覆蓋您的Application.mk文件中的一些設置。例如,它會覆蓋APP_ABI。您應該添加

defaultConfig { 
    ... 
    externalNativeBuild { 
     ndkBuild { 
      abiFilters "armeabi", "armeabi-v7a", "x86" 
     } 
    } 
} 

應用/的build.gradle。您不應該擔心最低支持版本爲android-14的警告,但請注意NDK r15目前仍處於測試階段。