Importing CMake project into Android Studio

I’m having a problems trying to import and sync my project (that uses cocos2d-x 3.17) into Android Studio.

I’m getting the following error:

ERROR: Cause: executing external native build for cmake <correct path to my CMakeLists.txt here>

Which basically only says that something is wrong with my CMakeLists.txt file, but it does not tell me what exactly. Is there any way I could make this message more verbose?

I’ve also tried building the project with:

./gradlew build --stacktrace

It did build correctly and afterwards I could import and sync the project into Android Studio, but the .apk crashed instantly, before it even got to executing any C++ code inside AppDelegate.cpp or even main.cpp.

Trying to step over Cocos’ Java parts resulted in strage errors about bytecode not matching source popping up, so I suspect that build did not go all that well either.

To be more specific, it crashed inside file:

cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java

on line 150:

nativeSetAudioDeviceInfo(isSupportLowLatency, sampleRate, bufferSizeInFrames);

Which is supposed to be the same for every generated project and simple HelloWorld works fine. I am really confused by this.

I’d rather do it all from Android Studio entirely (if possible) and without writing an Android.mk manually.

I’ve dug around more and found logs that pointed me to the CMake problems being:

CMake Error at CMakeLists.txt:58 (include):
  include could not find load file:

    CocosBuildSet


CMake Error at CMakeLists.txt:686 (cocos_build_app):
  Unknown CMake command "cocos_build_app".

It appears that they are on the cocos’ side and not my code. Any way I could rewrite these to be compatible without having to migrate my project to a newer cocos version?

UPDATE:

I’ve actually took time to write that Android.mk manually and it appears the problem is not CMake related at all. The crash is still there at the same line. It’s throwing an exception:

java.lang.UnsatisfiedLinkError: No implementation found for void org.cocos2dx.lib.Cocos2dxHelper.nativeSetAudioDeviceInfo(boolean, int, int) (tried Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetAudioDeviceInfo and Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetAudioDeviceInfo__ZII)

I’m building this on Ubuntu 18.04 LTS.

Anyone got any idea how to go about fixing this crash?