Configure Visual Studio 2017 to use existing Android SDK and NDK components

1k Views Asked by At

I have set up Visual Studio 2017 to work with Android NDK by installing Visual C++ Android tools, Apache ANT and configuring the locations of existing SDK, NDK and JDK locations.

I have installed LLDB, configured the clang.exe location and included all the headers from /ndk-bundle/sources.

I am trying to build the default Android Native Activity project. An older version can be found here: https://msdn.microsoft.com/en-us/library/dn707595.aspx

But still I am getting a lot of errors and all of the #includes underlined. When I try to build the solution I get the following error.

Severity Code Description Project File Line Suppression State Error TRK0002 Failed to execute command: "C:\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe @C:\Users\Saminda\AppData\Local\Temp\tmpcecf4937c8a14139b9405a2aae30e2e6.rsp". The handle is invalid. NDKSample.NativeActivity C:\Users\Saminda\source\repos\NDKSample\NDKSample\NDKSample.NativeActivity\TRACKER 1

Any help would be appreciated.

1

There are 1 best solutions below

2
Paulo Pinto On

Ant is no longer used by Android projects, replaced by Gradle.

After several experiments from the Android team, they ended up settling with Gradle + CMake, with ndk-build for legacy NDK projects.

Here is the Android documentation how to migrate to Gradle + CMake.

https://developer.android.com/studio/projects/add-native-code

https://developer.android.com/ndk/guides/cmake

I imagine you would need to update the build scripts in the generated project.