NDK HelloWorld项目:如何使用javah创建.h文件 [英] NDK HelloWorld project : How to create .h files using javah

查看:77
本文介绍了NDK HelloWorld项目:如何使用javah创建.h文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个helloWorld应用程序,该应用程序将打印日志.

I am trying to create a helloWorld app which will print a log..

  • 我尝试使用ndk编译项目
  • 在libs文件夹中创建.so文件

问题: -我不知道如何根据我的HelloWorld.java类创建机器生成的头文件 -是因为它给了我错误

Problem: - i dont know how to create machine generated header files according to my HelloWorld.java class - Is it because of that its giving me the Error

java.lang.UnsatisfiedLinkError: Native method not found

我的Android.mk文件看起来像

My Android.mk file looks like

 LOCAL_PATH := $(call my-dir)  
include $(CLEAR_VARS)  
LOCAL_LDLIBS := -llog  
LOCAL_MODULE    := ndk1  
LOCAL_SRC_FILES := hello.c  
include $(BUILD_SHARED_LIBRARY)  

推荐答案

对于Android Studio项目,命令如下所示:

For Android Studio projects the command reads like this:


cd C:\<path to your app>\src\main\java

javah -o ../jni/NameOfHeaderFile.h package.name.of.java.class.YourJavaClass

换句话说:导航到应用程序的"java"目录.此目录上方的一层应该是您的jni文件夹,头文件应该在该文件夹中.使用-o参数为头文件命名.告诉javah您要使用什么Java类来创建带有seconds参数的头文件.该Java类必须通过其完整的程序包名称来标识.

In words: Navigate to the "java" directory of your app. One level above this directory should be your jni folder where the header file should go. Give your header file a name with the -o parameter. Tell javah what Java class you wanna use to create the header file with the seconds parameter. This java class must be identified by its full package name.

这篇关于NDK HelloWorld项目:如何使用javah创建.h文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆