0

Step1: I extracted Android NDK to a directory where SDK is already there. Step2: Created a directory called Project_NDK in it. Step3: I have created the application.mk file and native.c file under jni folder . So where I should put C++ code?

4

1 回答 1

1

Typically, you don't place your code under the NDK folder, you place it in the subfolder called "jni" in the Android project. Before you start messing with NDK, you need a regular Android project with a manifest file. You can, in theory, create an NDK-only project without Java, but that's a pain.

In addition to Application.mk you need Android.mk. See the NDK docs for the guidance or look at hello-jni in the samples.

You place your C++ code into files with the .cpp extension, which go into the jni folder as well.

最后,请注意:不要仅仅因为 NDK 难以调试而使用它。对于基本的 Android 编程,只需使用 Java。如果您了解 C++ 而您不了解 Java,那么您将立即掌握它,它们已经足够接近了。

于 2013-03-30T19:42:09.720 回答