1

I have an Android project with a app/src/CMakeLists.txt file like this

cmake_minimum_required(VERSION 3.4.1)

add_library( # Specifies the name of the library.
             native-lib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             main/cpp/native-lib.cpp )

I also have a app/src/main/cpp/native-lib.cpp file in my project.

When I run ninja in a terminal I get this error

ninja: error: loading 'build.ninja': No such file or directory

I'm not familiar with the NDK and I'm trying to run the project with ninja but I'm not able to find any clear documentation or example.

1 Answer 1

4

Android NDK uses CMake to build projects, but instead of run ninja separately, you should run below gradle command to trigger your NDK project build.

./gradlew externalNativeBuild

Internally, CMake will use the ninja build system to compile and link the C/C++ sources for your apps.

Sign up to request clarification or add additional context in comments.

2 Comments

Here is my personal NDK example, hope it is helpful for your case: github.com/russell-shizhen/JniExample
Thank you shizhen, yes it is!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.