在AndroidNDK开发过程中,工程目录下的jni文件夹下编写的c/c++代码,通常会出现如下的几种类型的报错:
1、Unresolved inclusion:<XXX>
2、syntax error
3、Function 'XXX' could not be resolved
4、Type 'XXX' could not be resolved
5、Symbol 'XXX' could not be resolved
6、Method 'XXX' could not be resolved

7、Invalid arguments 'Candidates are: ...'

1 错误形式一:没有导入头文件(这是最大的错误,会引起一系列下面的报错)。通常会有如下表现形式:

1、Unresolved inclusion: <jni.h>、Unresolved inclusion: <stdio.h>、Unresolved inclusion: <malloc.h>、Unresolved inclusion: <Android/log.h>、...
2、Function '__android_log_print' could not be resolved、Type 'JNIEnv' could not be resolved、Type 'jstring' could not be resolved、Type 'jclass' could not be resolved、Function 'malloc' could not be resolved、Function 'memcpy' could not be resolved、Method 'FindClass' could not be resolved、Type 'jsize' could not be resolved、Symbol 'NULL' could not be resolved、...

解决方法:右击项目 --> Properties --> 左侧C/C++ General --> Paths and Symbols --> 右侧Includes --> GNU C++(.cpp) --> Add——>${NDKROOT}\platforms\android-18\arch-arm\usr\include(tips:这里的NDK platforms\android-18一定要和你的工程的properties里的target一致)。

2 错误形式二:

1、Unresolved inclusion: <iostream>、Unresolved inclusion: <fstream>、Symbol 'std' could not be resolved、..
2、Type 'fstream' could not be resolved、Symbol 'in' could not be resolved、Method 'seekg' could not be resolved、Method 'read' could not be resolved、...

解决方法:添加路径(步骤见上述解决方法):${NDKROOT}\sources\cxx-stl\gnu-libstdc++\4.8\include 、${NDKROOT}\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi\include。

3 错误形式三:Invalid arguments 'Candidates are:void * malloc(?)'、Invalid arguments 'Candidates are:void * memcpy(void *, const void *, ?)'

解决方法:添加路径(步骤见上述解决方法):${NDKROOT}\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.8\include


解决了错误,大家have fun微笑

更多相关文章

  1. FileProvider 路径配置策略的理解
  2. Android:常见错误提示
  3. android 获取路径目录方法以及判断目录是否存在,创建目录
  4. Ubuntu 13.04 编译环境配置及android 2.3 源代码编译时出现了以
  5. android之android.os.NetworkOnMainThreadException错误
  6. Gradle离线配置、.android、.AndroidStudio、.gradle、.m2缓存文
  7. Android WebView获取上一个链接的路径
  8. android提示错误: The process android.process.acore has stoppe
  9. Android 出现open failed: EACCES (Permission denied)错误**

随机推荐

  1. android sdk 安装更新慢:下载android sdk
  2. 配置Vim开发Android详解
  3. 2013学Android不得不看的13个视频课程(共
  4. Android(安卓)处理含有EditText的Activit
  5. android UI进阶之android中隐藏的layout
  6. Android-绘图机制总结
  7. Android(安卓)命名规范 (提高代码可以读性
  8. android五中方式调用服务service中的方法
  9. Android ***测试学习手册(三)Android 应用
  10. 如何从python代码中直接访问Android的Ser