How to interpret Android Studio build fail

I’ve got a project that compiles in XCode but fails in Android Studio. Below is the build output. It doesn’t help me get any closer to understanding what the problem is. Here’s some background: I started a project using cocos2d-x 3.12. A while later I upgraded to 3.17 and then noticed that the box2d files were modified (not just modified, but support has more or less be informally removed considering how many steps it takes to get box2d working). Instead of using the prebuilt box2d files, I included the source files as I needed a slightly modified version of box2d. So I got it to build in XCode. At that point it seemed my only issue was adding the proper dependencies to Android Studio, so I asked a question in these forums. The nice people tried to help, suggesting I update to 3.17.2 and use CMake and I edit the CMakeLists.txt. I also changed PROP_BUILD_TYPE=cmake in gradle.properties. And so that’s where I’m at. I can’t really tell what, if anything, CMake is doing. The README.md file in the cmake folder kind of explains how one might make various builds, but I don’t understand why anyone would do that since it’s already done for you when you use the cocos new command. I am really lost. I’ll RTFM if someone can point me to it.

build failed	456 ms
Run build	413 ms
Load build	2 ms
Configure build	144 ms
Calculate task graph	30 ms
Run tasks	235 ms
null	
API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.	
null	
/Users/some_guy/Documents/some_project/C++/proj.android	
../cocos2d/cocos/platform/android/java/src	
../../../../../../../../cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java	
error: cannot find symbol class DisplayCutout	
error: cannot find symbol variable P	
error: cannot find symbol variable layoutInDisplayCutoutMode	
error: cannot find symbol variable LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES	
error: cannot find symbol class DisplayCutout

Any chance you can create a new project with cocos2d-x 3.17.2, and then build that for Android to see if it works. Don’t add any of your code to it, just leave the project created from the template as-is.

Regardless of whether it works or not, it will at least help you narrow down the issue to either your setup, or the code. Which version of Android Studio? Which version of Android NDK?

1 Like

With PROP_BUILD_TYPE=cmake I ran the template “hello world” on both my Galaxy 6S Edge as well as the simulator. It was surprisingly relieving after so much indeterminate progress.

I suppose I could now try to add in the Box2D source files before adding in my classes and assets. Is the CMake activity logged anywhere? I’d like to see what’s happening, if possible.

Android Studio 3.4.1
NDK 20.0.5594570

Well, I see one difference, which is that you’re using NDK 20, and I’m still using 16, so at least I can set up the environment with the same settings to see if I can reproduce the issue.

To see what is happening with CMake, it usually logs everything to CMakeError.log and CMakeOutput.log, which are located in:
[your build folder]/CMakeFiles/

There are also flags you can pass to it for more verbose output. Have a read of the info here.

1 Like

This approached has been helpful, @R101, thanks! With a fresh project I was able to see how changing the CMakeLists.txt would affect the build. It finally clicked how CMake works, in a broad sense. At that point I managed to rebuild my project with the unmodified Box2D library and get it running on a couple test devices. I’m going to try and figure out a workaround for the Box2D we added.