giang.asl.8
giang.asl.8

Reputation: 313

Error when build NDK of AndEngine example

I'm trying to build AndEngine sample on my MacOS Android Studio 2.3.2. But get this error. Cannot figure out what is the problem. Strange thing is the same project build normally on Windows, same version of Android Studio.

> 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);
          ^

My Application.mk file:

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

And 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)

Upvotes: 4

Views: 6734

Answers (2)

Alex Cohn
Alex Cohn

Reputation: 57163

Android Studio overrides some settings in your Application.mk file. For example, it overrides APP_ABI. You should add

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

to your app/build.gradle. You should not be worried about the warning that minimum supported version is android-14, but please note that NDK r15, which is currently still in beta.

Upvotes: 2

AAryan
AAryan

Reputation: 20140

Android NDK: android-9 is unsupported. Using minimum supported version android-14.

Add APP_PLATFORM := android-14 in Application.mk file

If you do not have that line then version of your SDK is taken from project.properties files.

Upvotes: 3

Related Questions