错误:错误:'__ANDROID_API__'宏重新定义[-Werror,-Wmacro-redefined] -Android Studio

时间:2017-07-31 15:27:00

标签: java android android-ndk

我收到此错误,在我使用下面的“AndEngine”模块的项目中,

1)和发动机 2)和EnginePhysicsBox2DExtension 3)andEngineTexturePackerExtension

此前(2 - 3个月前),项目正在正常执行。现在,当我尝试执行代码时,我遇到了这个错误。

当我尝试评论“LOCAL_CFLAGS:= -Werror”行,来自“andEngine”模块的“Android.mk”时,我收到如下错误,

[armeabi-v7a] Compile++ arm  : andenginephysicsbox2dextension <= b2PolygonAndCircleContact.cpp
In file included from <built-in>:346:
<command line>:6:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
#define __ANDROID_API__ 14
        ^
<built-in>:338:9: note: previous definition is here
#define __ANDROID_API__ 9
        ^
error: error opening 'C:/Users/.../andEnginePhysicsBox2DExtension/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/andenginephysicsbox2dextension/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o.d': No such file or directory
1 warning and 1 error generated.
make: *** [C:/Users/.../andEnginePhysicsBox2DExtension/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/andenginephysicsbox2dextension/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o] Error 1

... FYI Android Studio:2.3.3。 NDK:是最新的。

先谢谢。

1 个答案:

答案 0 :(得分:1)

经过长时间的研究,终于得到了解决方案。

你所要做的就是,

1)在“andEngine”的“Android.mk”文件中,将“LOCAL_CFLAGS:= -Werror”替换为“LOCAL_CFLAGS:= -w”。其中,“-Werror”显示警告,因为它是一个错误,“-w”抑制与“andEngine”和其他模块相关的所有警告(不是实际错误)。

2)请清理项目,它应该适用于大多数情况。如果您仍然有一些错误,请按照步骤3进行操作。

3)您现在必须删除“ andEngine \ src \ main \”路径中的“jniLibs”文件夹(或者提取文件夹的路径代替“和引擎“在那个错误中”并重新编译代码。

  

错误:任务'执行失败:和引擎:transformNativeLibsWithMergeJniLibsForDebug'。   在OS独立路径'lib / x86 / libandengine.so'

中找到了多个文件

谢谢大家的意见/建议。