@IcemarkUK posted a new topic, subject "Cocos, CMake, and Android". It read:

   So, I am now finally turning my attention to the Android build. But as usual it looks like I am missing something.
    
    I have used CMake to create the iOS, OSX, and Win32 builds without issue.
    
    There is an proj.android folder from when the original project was created. But this is obviously not up to date.
    
    So what CMake command line do I use to create the latest project?
    
    I checked the docs and it suggests two changes to make to gradle files which I did. Then I loaded the project into android studio but it fails…  
    
    
    Screenshot barrmichelle@example.com×744 92.8 KB
    
    The NDK is however installed.
    
    Screenshot barrmichelle@example.com×1054 215 KB
    
    Screenshot barrmichelle@example.com×498 93 KB
    
    Pointers…?

After which, @IcemarkUK added

    So I get a little closer… even though NDK is installed it's not in my local.properties
    
    Screenshot barrmichelle@example.com×1192 185 KB

So @IcemarkUK replied

    But now it's really helpful…  
    
    
    Screenshot barrmichelle@example.com×536 59.9 KB

Then @IcemarkUK said

    Screenshot barrmichelle@example.com×1408 409 KB

To which @IcemarkUK replied

    Updated gradle and it now gets further… however
    
    Screenshot barrmichelle@example.com×642 271 KB

@R101 replied

    IcemarkUK:
    
    > There is an proj.android folder from when the original project was created. But this is obviously not up to date.
    
    That folder is up-to-date, in the sense that it's just configuration files and source files (both C++ and Java). The changes in here aren't directly related to CMake, but rather to your Android project.
    
    IcemarkUK:
    
    > So what CMake command line do I use to create the latest project?
    
    Android Studio will automatically update the temporary build files using CMake any time it detects a changes in one of your build configuration files (like CMakeLists.txt or gradle.build etc).
    
    The `ndk.dir` field in `local.properties` is deprecated, and the NDK should be set in your `/app/build.gradle` file, exactly as it is indicating in the log. For example:
    [code] 
        ...
        
        repositories {
            google()
        }
        
        android {
            compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
            ndkVersion "801-760-1735"
        
            defaultConfig {
        ...
        
    [/code]
    
    It will automatically find the correct version of the NDK, as long as it is exactly where it expects it to be, in `[android sdk folder]/sdk/ndk/[ndk folder named as version number, must match ndkVersion in build.gradle]`.
    
    Now, the warning you see with the 32-bit architecture is related to this in `gradle.properties`:
    [code] 
        # List of CPU Archtexture to build that application with
        # Available architextures (armeabi-v7a | arm64-v8a | x86)
        # To build for multiple architexture, use the `:` between them
        # Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86
        PROP_APP_ABI=armeabi-v7a:arm64-v8a
        
    [/code]
    
    If you add “x86” to that list, then you _must_ also add the 64 bit version, but, it won't work with Cocos2d-x because the x86_64 3rd party libraries are missing. There are very few x86/x86_64 devices out there, so personally, I don't think you should be concerned about that. If you really want to support the x86_64 architecture, then you'll have to build the 3rd party libraries from source yourself.
    
    To get rid of that warning, just change it to this:  
    `PROP_APP_ABI=armeabi-v7a:arm64-v8a`

Then @IcemarkUK said

    R101:
    
    > ` ndkVersion "801-760-1735"`
    
    Thanks I think I'm there… possibly the documentation needs a tweak to cover the above?

To which @IcemarkUK replied

    It builds and deploys… just go to get it to run now!

To which @system replied

    This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.


{'source': 'discourse', 'url': 'https://discuss.cocos2d-x.org/t/cocos-cmake-and-android/52300', 'title': 'Cocos, CMake, and Android', 'views': 379, 'has_accepted_answer': True, 'word_count': 620, 'like_count': 0, 'reply_count': 1, 'participant_count': 2, 'posts': 9, 'tags': '', 'author': '@IcemarkUK', 'participants': '@IcemarkUK, @R101, @system', 'image_url': ['https://discuss.cocos2d-x.org/uploads/default/optimized/3X/0/6/0660982856367e0ef76ececb3010cb7d9beb708d_2_1024x397.png'], 'created_at': '2020-12-18T02:01:49.777Z', 'last_posted_at': '2020-12-19T21:06:44.307Z'}