android ndk r10d,Configuring Android Studio to use NDK (android-ndk-r10d, Windows 64-bit)

I have an application I'm trying to compile, which uses *.c files.

To compile this I must use NDK.

Downloaded the 64bit version and browsed the net to find tips on configuring gradle.

It seems the config is ok, and gradle attempts to run the NDK build process.

It does this by calling ndk-build.cmd and stops with this error:

\AppData\Local\VirtualStore\Windows\SysWOW64\android-ndk-r10d\ndk-build.cmd": CreateProcess error=2, The system cannot find the file specified

I searched the whole folder for ndk-build.cmd, but there is none.

What in the world am I missing?

EDIT1: The NDK is installed here:

#ndk.dir=C\:\\Users\\user\\AppData\\Local\\VirtualStore\\Windows\\SysWOW64\\android-ndk-r10d

EDIT2: I did try my system path is OK, this is not the problem. I did however instal the 32-bit version, and this one does have the *.cmd file.

I can now compile the *.c files.

I used this command in the AndroidStudio Terminal:

ndk-build -C C:\Users\Thatisme\AndroidStudioProjects\DeezerAP2\app\src\main\jni

All *.c, *.h, *.mk and *.sh were placed in the jni folder as seen in the picture bellow.

EDIT3: I can now generate *.so files, but for some reason, the native methods are not found.

EDIT4:

This is how my project looks like:

01d720a56ea18f923b93980eaee0dd56.png

I manually copied the *.so files in the jniLibs folder.

Is the declaration of the *.c function OK?

JNIEXPORT jobject JNICALL Java_com_lexample_liggy_ldeezerap_SerialPort_open

(JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)

EDIT5: I finally did it. The correct name of the function is:

JNIEXPORT jobject JNICALL Java_com_example_iggy_deezerap_SerialPort_open

(JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)

Package name is: com.example.iggy.deezerap

Java file calling the function "open()" is: SerialPort

The source file containing the native function is named: SerialPort.c

The function beeing called is: open()

I recompiled the *.c files, copied them also in jniLibs, recompiled the Android project and now it works.

I'm pretty sure I had this before and I strongly suspect it was due to some sort of mismatch error in the *.c functions.

About the thing in bold:

JNIEXPORT jobject JNICALL Java_com_example_iggy_deezerap_SerialPort_open

(JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)

Does this refer to the *.c file or the *.java file?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值