今天在抽出了一点时间准备在Android studio上实现jni编程。
按照步骤创建了一个带c++的android项目,编译的时候问题来了:
环境:
Android studio2.3.2
jdk1.8.0
sdk25
ndk14.1
问题
1.JNIEXPORT和JNICALL都提示Error after macro substitution: Microsoft attributes are not supported by the complier
error: unknown type name '__declspec'
2.__int64认不到
解决办法:
在网上爬了很久,没有在解决办法。
最后总结网上说的和根据自己经验:
问题产生的原因:
1.是编译工具不支持window的导出动态库的属性声明,
JNIIMPORT __declspec(dllimport)
JNICALL __stdcall
2.linux环境下需要定义jlong为long long
最终修改${JAVA_HOME}\include\win32\jni_md.h文件如下
问题解决,mark一下,备查。
最后