安卓NDK流程
- 定义wrap类,声明native函数,加载库
package com.ndk.hello;
public class Classs {
public native String say_hello();
static
{
System.loadLibrary("HelloAndroidNDK");
}
}
- 在项目根目录创建jni文件夹,在此文件夹生成JNI头文件
javah -classpath ../bin/classes com.ndk.hello.Classs
- 为生成的com_ndk_hello_Classs.h写实现文件
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_ndk_hello_Classs */ #ifndef _Included_com_ndk_hello_Classs
#define _Included_com_ndk_hello_Classs
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_ndk_hello_Classs
* Method: say_hello
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_ndk_hello_Classs_say_1hello
(JNIEnv *, jobject); #ifdef __cplusplus
}
#endif
#endif
#include "com_ndk_hello_Classs.h" JNIEXPORT jstring JNICALL Java_com_ndk_hello_Classs_say_1hello(JNIEnv * env, jobject this)
{
return (*env)->NewStringUTF(env,"Hello Java NDK!");
}
- 在jni文件夹写Android.mk文件
# Copyright (C) The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := HelloAndroidNDK
LOCAL_SRC_FILES := com_ndk_hello_Classs.c include $(BUILD_SHARED_LIBRARY)
- 在jni文件夹中交叉编译mk文件
$NDK/ndk-build
- 将生成libs/armeabi/libHelloAndroidNDK.so文件
- 编写安卓框架程序,调用native方法。
package com.ndk.hello;
import com.ndk.hello.Classs;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView; public class HelloAndroidNDK extends Activity{
@Override
public void onCreate(Bundle s)
{
super.onCreate(s); Classs c = new Classs(); String say = c.say_hello();
TextView tv = new TextView(this);
tv.setText(say);
setContentView(tv);
}
}
安卓NDK流程的更多相关文章
- EClipse开发NDK流程
EClipse开发NDK流程(现在studio也在2.2之后支持了非常简单,只要创建项目的时候勾选c++支持就可以了) 什么情况下使用ndk,1.保护代码,java很容易反编译,c/c++反汇编比 ...
- 如何做个简单安卓App流程
有同学做毕业设计,问怎样做个简单安卓App流程,我是做服务端的,也算是经常接触app,想着做app应该很简单吧,不就做个页面,会跳转,有数据不就行了,我解释了半天,人家始终没听懂,算了,我第二天问了下 ...
- 开发安卓安装流程(codorva+ionic)
开发安卓安装流程 0 安装操作系统 Win10 用户名称尽量英文字母加数字,避免编码问题 1 安装Java sdk 1.8.0_45 所需文件 jdk-8u45-windows-x64 1. ...
- 完整版unity安卓发布流程(包括SDK有原生系统依赖关系的工程)
要3个东西!NDS,SDK,JDK, NDK官网下载:https://developer.android.google.cn/ndk/downloads/index.html(注意系统是不是64位) ...
- 安卓ndk参考资料
http://developer.samsung.com/technical-doc/view.do;jsessionid=xKa-L5xQDvdrSyc1sN71lHAXjcv2YUH7I92zjH ...
- [lua]安卓ndk如何编译lua库
这里说的lua库是标准lua库,不包含tolua,不包含cocos2dx的各种lua扩展,是干净的lua. 参考: http://stackoverflow.com/questions/1229965 ...
- 网页打包安卓APP流程
搭建环境过程: 1. 安装JDK. 参见http://www.cnblogs.com/Li-Cheng/p/4334985.html. 注:实质上到该网址上下载好JDK安装包,安装后添加一个环境变量: ...
- 安卓ndk 忽略 error: undefined reference to '找不到符号
最近在搞天使之翼的mrp模拟器... 移到AndroidStudio了,现在想把原来的Android .mk那种方式的改成cmake的方式编译,但是编译时有一些符号找不到. undefined ref ...
- Linux下安卓ndk混合编译调用so方法——QuickStart学习
转自:http://www.52pojie.cn/thread-313869-1-1.html #注意:.h 和.c中的错误eclipse不会检查,只会调用时在手机或虚拟机中死掉.因此需要仔细检查其中 ...
随机推荐
- POJ 2229 Sumsets(规律)
这是一道意想不到的规律题............或许是我比较菜,找不到把. Description Farmer John commanded his cows to search for diffe ...
- day_02 循环格式化输出编码运算符
1.while循环 语法 while 条件: 循环体 else: 当条件不成立的时候执行这里,和break没关系 如果循环是通过break退出的. 那么while后面的else将不会被执行, 只有在w ...
- .Net默认IE版本号的两种方式
1.直接在页面的header部位meta标签中加入如下代码 <meta http-equiv="X-UA-Compatible" content="IE=8&quo ...
- 服务器运行两个或两个以上的tomcat
一:解决方法 转载: https://www.cnblogs.com/xiaobai1226/p/7662392.html 二:解决方法 将tocmat下 bin---->tomcat8w.e ...
- 8 Operator overloading
在类中,Groovy支持你使用标准的操作符.例如,如果你想使用a+b操作(a和b来自于Z类),那么你在Z类中,必须实现(implement)plus(Zname)方法.
- 第一章javascript简介
javascript 当诞生于1995 最开始是目的是处理在服务器端进行的表单验证:让其在服务器端验证改为在服务端验证,大大提高速度(当时网络慢) 如今javascript是一门功能全面的语言,包含闭 ...
- Hbase 表操作
1. list 操作 2. 创建table column family, 3. 插入数据: put 'user' 3. 检索数据: scan table
- Fiddler相关配置
1.General 2.HTTPS: 3.Connections 4.Gateway 5.appearance 6.Scripting url过滤: REGEX:\.(js|css|png|gif|h ...
- 数据结构---Java---HashMap
1.概述 [hash冲突]: 对某个元素进行哈希函数运算,得到一个地址值,要进行插入时,发现此地址被占用,称为hash冲突(哈希碰撞): [hash冲突解决]: 开放定址(发生冲突,继续寻找下一块未被 ...
- RTT学习之BSP
---恢复内容开始--- 一 根据相近型号的demo BSP进行修改制作自己的BSP https://github.com/RT-Thread/rt-thread/blob/master/bsp/st ...