AndroidNDK



###

NDK官网示例 googlesamples/android-ndk


CrystaX NDK

Boost + Android? CrystaX NDK!
使用Android Studio构建基于NDK和Boost C++库的应用程序


不错的 ndk 文章

Android ndk入门学习
JNI系列教程三 —— NDK入门
MENU Android Studio中NDK开发
Android Studio, gradle and NDK integration
NDK-JNI实战教程(一) 在Android Studio运行第一个NDK程序
NDK-JNI实战教程(二) JNI官方中文资料
Android Studio ndk-Jni开发详细入门,Aes加密demo
国外不错的文章-The new NDK support in Android Studio


出现错误

1
2
3
4
 /home/user5432/workspace/bitmapproj/obj/local/armeabi/objs-debug/mybitmap.o : In function Java_com_example_plasma_PlasmaView_renderPlasma
"undefined reference to AndroidBitmap_getInfo"
"undefined reference to AndroidBitmap_lockPixels"
"undefined reference to AndroidBitmap_unlockPixels"

gradle ndk 添加如下依赖

1
2
3
ndk {
ldLibs "log","android", "jnigraphics" // 引用依赖的 ndk 库 ldLibs = ["android", "jnigraphics", <other ndk libraries you might need>]
}

或 Android.mk 添加如下依赖

1
`LOCAL_LDFLAGS += -ljnigraphics`

参考
Android bitmap native code - linking problem


出现 NEON 错误

1
Error:(31, 2) error: #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h

Android NDK(ARM开发)使用NEON优化
Android NDK使用NEON优化,SIMD优化
Gradle - neon
How do I enable ARM NEON builds using Gradle?
How to build and debug native code (c) with neon enabled in android studio?
Android-NDK _NEON Support


error Unknown or unsupported ARM architecture

[revamp] Android NDK API 21 issue #455

1
2
3
4
5
6
7
8
9
It would appear that at least as of Kitkat 4.4 (API 19), ARM devices are required to be at least ARMv7a:

MUST report, via android.os.Build.CPU_ABI, only one of the ABIs listed below
* armeabi-v7a
* x86
* mips
It's not altogether surprising that the API to follow 19 (Lollipop API 21) would drop support for ARMv5 completely. From what I've read, official builds of 4.4+ are always ARMv7a, but there are some custom builds for certain devices which run ARMv6.

So the fix is to target a lower API or target the armeabi-v7a architecture. Switching to v7a fixed this problem for me.

我的错误信息大概是 android-23/…/cpu-feature.h 中的错误,可能是最新的 ndk 暂不支持 cpu-feature.h 的 armeabi 平台编译库吧, 去掉 abiFilters 中的 armeabi 编译选项即可

1
abiFilters "armeabi-v7a" , "x86", "mips" //"armeabi", "armeabi-v7a" , "x86"

错误 Error:(208, 9) error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

1
2
3
4
5
C:\Users\yafei\AppDeveloperWorkspace\CoamAndroid\app\src\main\jni\audio.c
Error:(208, 9) error: 'for' loop initial declarations are only allowed in C99 or C11 mode
Information:(208, 9) use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
C:\Users\yafei\AppDeveloperWorkspace\CoamAndroid\app\src\main\jni\audio.c: In function 'Java_com_coam_ui_telegram_controller_TelegramMediaController_getWaveform2':
C:\Users\yafei\AppDeveloperWorkspace\CoamAndroid\app\src\main\jni\audio.c:692:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode

Building android app with C++
Gradle building issue


Telegram 相关


ogg 没有 config_types.h 错误

xiph/ogg
添加文件 rtn56u/user/flac-1.2.1/source/include/ogg/config_types.h


cpu-feature 问题

The cpufeatures Library


文章目录
  1. 1. CrystaX NDK
  2. 2. 不错的 ndk 文章
  3. 3. 出现错误
  4. 4. 出现 NEON 错误
  5. 5. error Unknown or unsupported ARM architecture
  6. 6. 错误 Error:(208, 9) error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
  7. 7. Telegram 相关
  8. 8. ogg 没有 config_types.h 错误
  9. 9. cpu-feature 问题