AndroidStudio2.2 cmake编译找不到 [项目目录]/cocos2d/external/下的库

AndroidStudio2.2 cmake编译找不到 [项目目录]/cocos2d/external/下的库。

1、所用cocos2d-x版本:3.13.1,所建项目名:AsCocos,ndk版本:ndk-r13b
2、 系统为Ubuntu16.10,用Clion使用系统cmake(-version=3.5.2)可以编译运行出Linux版本程序;
3、 命令行使用cocos run -p linux可以正常运行linux版,且在输出中可以看到cmake可以找到 [项目目录]/cocos2d/external/下需要的文件。
4、 命令行使用cocos run -p android可以使用pro.android/jni下面的Android.mk编译出apk,并可以正常运行;
5、 AndroidStudio 2.2.2(使用Androidsdk/cmake/下的cmake,-version=3.6.0-rc2)导入cocos创建的项目,gradle中添加

cmake配置信息,但是系统检查的时候提示:

Error:A problem occurred configuring project ':AsCocos'.
> executing external native build for cmake /home/seven/dev/ws/cocos/AsCocos/CMakeLists.txt

具体报错内容为:

It appears you are cross compiling for  with Clang
CMake Error at cocos2d/cmake/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
  这里→Could NOT find WebP (missing: WEBP_LIBRARIES WEBP_INCLUDE_DIR)←这里
Call Stack (most recent call first):
  cocos2d/cmake/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
  cocos2d/cmake/Modules/FindWebP.cmake:67 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cocos2d/cmake/Modules/CocosBuildHelpers.cmake:44 (find_package)
  cocos2d/cmake/Modules/BuildModules.cmake:40 (cocos_find_package)
  cocos2d/CMakeLists.txt:98 (BuildModules)

cocos run -p linux时,终端输出是可以找到的:

seven@seven-Lenovo-G565:~/dev/ws/cocos/AsCocos$ cocos run -p linux
编译模式:debug
正在执行:'cmake -DCMAKE_BUILD_TYPE=Debug -DDEBUG_MODE=ON ..'

It appears you are builing natively for Linux with GCC
-- OpenGL include dirs: /usr/include
-- GLEW include dirs: /usr/include
-- PkgConfig found
-- GLFW3 include dirs: /usr/include/GLFW
-- SQLite3 include dirs: /usr/include
-- FMOD include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/linux-specific/fmod/include
-- Fontconfig include dirs: /usr/include/freetype2
-- GTK3 include dirs: /usr/local/include;/usr/include/gtk-3.0;/usr/include/at-spi2-atk/2.0;/usr/include/at-spi-2.0;/usr/include/dbus-1.0;/usr/lib/x86_64-linux-gnu/dbus-1.0/include;/usr/include/gtk-3.0;/usr/include/gio-unix-2.0/;/usr/include/mirclient;/usr/include/mircommon;/usr/include/mircookie;/usr/include/cairo;/usr/include/pango-1.0;/usr/include/harfbuzz;/usr/include/pango-1.0;/usr/include/atk-1.0;/usr/include/cairo;/usr/include/pixman-1;/usr/include/freetype2;/usr/include/libpng16;/usr/include/gdk-pixbuf-2.0;/usr/include/libpng16;/usr/include/glib-2.0;/usr/lib/x86_64-linux-gnu/glib-2.0/include
-- Freetype include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/freetype2/include/linux;/home/seven/dev/ws/cocos/AsCocos/cocos2d/external/freetype2/include/linux

下面这行↓
-- WebP include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/webp/include/linux
上面这行↑

-- Chipmunk include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/chipmunk/include
-- Bullet include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/bullet
-- Recast include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/recast
-- TinyXML2 include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/tinyxml2
-- JPEG include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/jpeg/include/linux
-- ZLIB include dirs: /usr/include
-- MINIZIP include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/unzip;/usr/include
-- PNG include dirs: /usr/include;/usr/include
-- TIFF include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/tiff/include/linux
-- WEBSOCKETS include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/websockets/include/linux
-- CURL include dirs: 
-- Flatbuffers include dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external
-- OPENGL add to include_dirs: /usr/include
-- OPENGL libs added to 'cocos2dInternal': /usr/lib/x86_64-linux-gnu/libGLU.so;/usr/lib/x86_64-linux-gnu/libGL.so
-- GLEW add to include_dirs: /usr/include
-- GLEW libs added to 'cocos2dInternal': /usr/lib/x86_64-linux-gnu/libGLEW.so
-- GLFW3 add to include_dirs: /usr/include/GLFW
-- GLFW3 libs added to 'cocos2dInternal': glfw
-- GLFW3 add definitions: -DGLFW_DLL
-- FMOD add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/linux-specific/fmod/include
-- FMOD libs added to 'cocos2dInternal': /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so;/home/seven/dev/ws/cocos/AsCocos/cocos2d/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so
-- FONTCONFIG add to include_dirs: /usr/include/freetype2
-- FONTCONFIG libs added to 'cocos2dInternal': fontconfig;freetype
-- THREADS libs added to 'cocos2dInternal': -lpthread
-- GTK3 add to include_dirs: /usr/local/include;/usr/include/gtk-3.0;/usr/include/at-spi2-atk/2.0;/usr/include/at-spi-2.0;/usr/include/dbus-1.0;/usr/lib/x86_64-linux-gnu/dbus-1.0/include;/usr/include/gtk-3.0;/usr/include/gio-unix-2.0/;/usr/include/mirclient;/usr/include/mircommon;/usr/include/mircookie;/usr/include/cairo;/usr/include/pango-1.0;/usr/include/harfbuzz;/usr/include/pango-1.0;/usr/include/atk-1.0;/usr/include/cairo;/usr/include/pixman-1;/usr/include/freetype2;/usr/include/libpng16;/usr/include/gdk-pixbuf-2.0;/usr/include/libpng16;/usr/include/glib-2.0;/usr/lib/x86_64-linux-gnu/glib-2.0/include
-- GTK3 libs added to 'cocos2dInternal': gtk-3;gdk-3;pangocairo-1.0;pango-1.0;atk-1.0;cairo-gobject;cairo;gdk_pixbuf-2.0;gio-2.0;gobject-2.0;glib-2.0
-- GTK3 add definitions: -pthread
-- ZLIB add to include_dirs: /usr/include
-- ZLIB libs added to 'cocos2dInternal': /usr/lib/x86_64-linux-gnu/libz.so
-- MINIZIP add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/unzip;/usr/include
-- MINIZIP libs added to 'cocos2dInternal': unzip;/usr/lib/x86_64-linux-gnu/libz.so
-- JPEG add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/jpeg/include/linux
-- JPEG libs added to 'cocos2dInternal': /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/jpeg/prebuilt/linux/64-bit/libjpeg.a
-- PNG add to include_dirs: /usr/include;/usr/include
-- PNG libs added to 'cocos2dInternal': /usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libz.so
-- TIFF add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/tiff/include/linux
-- TIFF libs added to 'cocos2dInternal': /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/tiff/prebuilt/linux/64-bit/libtiff.a
-- TinyXML2 add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/tinyxml2
-- TinyXML2 libs added to 'cocos2dInternal': tinyxml2
-- FREETYPE add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/freetype2/include/linux;/home/seven/dev/ws/cocos/AsCocos/cocos2d/external/freetype2/include/linux
-- FREETYPE libs added to 'cocos2dInternal': /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/freetype2/prebuilt/linux/64-bit/libfreetype.a
-- WEBSOCKETS add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/websockets/include/linux
-- WEBSOCKETS libs added to 'cocos2dInternal': /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/websockets/prebuilt/linux/64-bit/libwebsockets.a
-- CURL libs added to 'cocos2dInternal': curl
-- FLATBUFFERS add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external
-- XXHASH add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/xxhash
-- XXHASH libs added to 'cocos2dInternal': xxhash
-- WEBP add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/webp/include/linux
-- WEBP libs added to 'cocos2dInternal': /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/webp/prebuilt/linux/64-bit/libwebp.a
-- CHIPMUNK add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/chipmunk/include
-- CHIPMUNK libs added to 'cocos2dInternal': /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/chipmunk/prebuilt/linux/64-bit/libchipmunk.a
-- BULLET add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/bullet
-- BULLET libs added to 'cocos2dInternal': bullet
-- RECAST add to include_dirs: /home/seven/dev/ws/cocos/AsCocos/cocos2d/external/recast
-- RECAST libs added to 'cocos2dInternal': recast
-- Configuring done
-- Generating done
-- Build files have been written to: /home/seven/dev/ws/cocos/AsCocos/linux-build
正在执行:'make -j8'

[  0%] Built target MyGame_CORE_PRE_BUILD
[  1%] Built target unzip
[  1%] Built target xxhash
[  2%] Built target flatbuffers
[  3%] Built target tinyxml2
MyGame_PRE_BUILD ...
[  5%] Built target recast
[  5%] Built target MyGame_PRE_BUILD
[ 25%] Built target bullet
[100%] Built target cocos2dInternal
[100%] Built target cocos2d
[100%] Built target MyGame
编译成功。
部署模式:debug
启动应用。
正在执行:'/home/seven/dev/ws/cocos/AsCocos/bin/debug/linux/MyGame'

Ready for GLSL
Ready for OpenGL 2.0

webp的include下各个平台都不缺:

如果注释掉cmake中查找WebP的内容,则会继续往下报[项目目录]/cocos2d/external/下其他库找不到(如Chipmunk),所以看来external/下的都找不到。

怎么解?
求指点~
先行谢过,不胜感激。

话说发帖支持md吗?怎么语法怪怪的,似乎还不支持行内加粗之类的嵌套…

AndroidStudio 现在还没有支持编译c++,现在还是需要cocos命令先编译c++代码,再用AndroidStudio生成APK。

帖子是支持markdown格式的。

Android Studio 2.2开始不是支持cmake和ndk-build两种方式编译c++了吗?
参考资料

我的意思是引擎这边的支持还没有,因为我们希望是能够在AndroidStudio里编译调试。具体可以看这个PR:https://github.com/cocos2d/cocos2d-x/pull/15676

你好,你所发的这个链接里面不就是在讨论使用cmake的as工程吗?还有里面的 chaoren 的github https://github.com/chaoren/cocos2d-x/blob/cmake/templates/cpp-template-default/proj.android-studio/app/build.gradle

是的,chaoren是google的开发人员。