Search code examples
androidc++android-ndkandroid-studio-2.0

NDK in Android Studio not working for C++ files


In latest Android Studio 2.0 I am trying to run the ndk example, but build is breaking with the following error:

/Users/ktulsia/AndroidStudioProjects/example/app/src/main/jni/hello-jni.cpp
Error:(18, 18) string: No such file or directory
compilation terminated.
Error:Execution failed for task ':app:compileArm64-v8aDebugHello-jniSharedLibraryHello-jniMainCpp'.
> A build operation failed.
  C++ compiler failed while compiling hello-jni.cpp.
See the complete log at: file:///Users/ktulsia/AndroidStudioProjects/example/app/build/tmp/compileArm64-v8aDebugHello-jniSharedLibraryHello-jniMainCpp/output.txt

Solution

  • As i was very new to NDK it took some time to figure out the approach and options.

    here are two very nice pages i have found which helped solve almost all the issues. and understand how the latest Android studio works with NDK.

    link 1 link 2

    even though i referred the above pages but I tried the NDK on Android studio 2.0 and it is working fine. so wanted to share the same