读书人

Android NDK使用常见异常

发布时间: 2012-09-09 09:27:54 作者: rapoo

Android NDK使用常见错误

Andorid NDK使用简要的流程【来源于Android NDK文档中的 OVERVIEW.txt】

Here’s a very rough overview of how you can develop native code with the Android NDK:

1/ Run ??build/host-setup.sh to configure the NDK
2/ Place ?your native sources under $PROJECT/jni/…
3/ Write ?$PROJECT/jni/Android.mk? to describe your sources to the NDK build system
4/ Write ?apps/<myapp>/Application.mk to describe your application and the native sources it needs to the NDK build system
5/ Build ?your native code by running “make APP=<myapp> ” in the top-level NDK directory.

The last step will copy, in case of success, the stripped shared libraries your application needs to your application’s root project directory. You will then need to generate your final .apk through the usual means.

按照上述步骤,我们说明在每一步中可能存在的错误【第一步,我们就不在这里详细说了,网上有很多不错的文章】。

常见错误说明:

1、make:*** No rule specified and no make file found. Stop.

Android NDK使用常见异常
错误的原因估计是(cat : Linux命令,显示文件的内容):工程名与Aplication.mk中的APP_MOUDLES不一致。

Android NDK使用常见异常

2、make: *** No rule to make target ?“XXXXXX”, needed by “ndk-app-XXXXX”. Stop.

Android NDK使用常见异常

这个错误的主要原因是:编译C文件为最后的so库文件需要2个文件:Application.mk、Android.mk,如下图所示:

Android NDK使用常见异常

MK文件如何设置,看了上面的图一目了然【详细的说明还是要去看文档】,以下几点需要注意:

读书人网 >Android

热点推荐