Error when using ndk-build in android studio

35 Views Asked by At

I would like to build c++ code with Android Studio instead of using ndk-build script manually. I've used script from Stockfish Open Source Chess Engine and i have used Android.mk and ndk-build script to build.

This project works successfully when run in android studio. However, Android Studio is unable to build the APK or Bundle files because the native code is not neon-compatible.

In my build.gradle, i have the following lines:

externalNativeBuild {
        ndkBuild {
            path file('src/main/cpp/Android.mk')
        }
    }

Stockfish executables to assets directory:

task copyToJniLibs(type: Copy, dependsOn: 'externalNativeBuildRelease') {
    from('build/intermediates/ndkBuild/release/obj/local') {
        include '*/stockfish'
        include '*/stockfish_nosimd'
    }
    into 'src/main/jniLibs'

    eachFile { FileCopyDetails fileDetails ->
        def fileName = fileDetails.name + '.so'
        fileDetails.path = fileDetails.path.replace(fileDetails.name, fileName)
    }
}

tasks.withType(JavaCompile) {
    t -> t.dependsOn copyToJniLibs
}

android {
    applicationVariants.all { variant ->
        tasks["merge${variant.name.capitalize()}JniLibFolders"]
                .dependsOn(copyToJniLibs)
    }
}

When i try to build APK, on the Build tab i see the following error:

[CXX1429] error when building with ndkBuild using D:\Android\base_functionality_app\app\src\main\cpp\Android.mk: C++ build system [configure] failed while executing:
    @echo off
    "C:\\Users\\tioth\\AppData\\Local\\Android\\Sdk\\ndk\\25.1.8937393\\ndk-build.cmd" ^
      "NDK_PROJECT_PATH=null" ^
      "APP_BUILD_SCRIPT=D:\\Android\\base_functionality_app\\app\\src\\main\\cpp\\Android.mk" ^
      "NDK_APPLICATION_MK=D:\\Android\\base_functionality_app\\app\\src\\main\\cpp\\Application.mk" ^
      "APP_ABI=armeabi-v7a" ^
      "NDK_ALL_ABIS=armeabi-v7a" ^
      "NDK_DEBUG=0" ^
      "APP_PLATFORM=android-26" ^
      "NDK_OUT=D:\\Android\\base_functionality_app\\app\\build\\intermediates\\cxx\\Release\\1x41n496/obj" ^
      "NDK_LIBS_OUT=D:\\Android\\base_functionality_app\\app\\build\\intermediates\\cxx\\Release\\1x41n496/lib" ^
      "APP_SHORT_COMMANDS=false" ^
      "LOCAL_SHORT_COMMANDS=false" ^
      -B ^
      -n
  from D:\Android\base_functionality_app\app
C:/Users/tioth/AppData/Local/Android/Sdk/ndk/25.1.8937393/build/../build/core/build-binary.mk:259: *** Android NDK: Building non-Neon code is no longer supported.    .  Stop.
0

There are 0 best solutions below