我能够遵循jni教程就好了。但是当我改变方法名称时,我遇到了麻烦。是否有一个我需要遵循的命名约定?本教程使用HelloJNI作为模块名称和库名称。我用“useaaacom”。java原生接口方法和模块名称的命名约定是什么?
我对此有很好的反馈,我正在取得进展。我有一个相关的问题;让我知道我是否应该为它创建另一个帖子。我喜欢在这个应用程序上构建,该应用程序在此处运行。我如何从设备驱动程序调用函数?我有头文件,并将驱动程序加载到我的映像中。我的意思是,我需要在我的项目中有一个头文件的副本吗?该设备驱动程序由供应商实施,即不属于AOSP的一部分。自从我下载了整个开源项目并构建它之后,我确实有一份它的副本。所以我问的是我需要什么在我的apk中的应用程序来调用功能,这是属于有源设备驱动程序的一部分?
让我知道我是否应该更多的解释的任何部分,或者我需要张贴的头文件或....
我已经验证了我可以打开一个设备驱动器,具有以下几行代码:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char **argv)
{
/* Our file descriptor */
int fd;
int rc = 0;
char *rd_buf[16];
printf("%s: entered\n", argv[0]);
/* Open the device */
fd = open("/dev/hello1", O_RDWR);
if (fd == -1) {
perror("open failed");
rc = fd;
exit(-1);
}
printf("%s: open: successful\n", argv[0]);
/* Issue a read */
rc = read(fd, rd_buf, 0);
if (rc == -1) {
perror("read failed");
close(fd);
exit(-1);
}
printf("%s: read: returning %d bytes!\n", argv[0], rc);
close(fd);
return 0;
}
我想我需要上面的代码添加到我的JNI夹在.C源文件的形式,并从该文件调用我的设备驱动程序头文件中的函数?您可能已经注意到上面的代码是针对名为“hello1”的测试设备驱动程序。我要将名称更改为我的目标设备驱动程序。
方法名称必须与JNI函数名称匹配。 – nneonneo