使用Android Studio自带的NDK编译JNI
/**********************************************************************************
* 使用Android Studio自带的NDK编译JNI
* 说明:
* 省得自己另外去下载NDK,编译JNI,麻烦。
*
* 2017-4-30 深圳 龙华民治樟坑村 曾剑锋
*********************************************************************************/ 一、参考文档:
. NDK环境搭建-windows篇
http://www.jianshu.com/p/708e6bf68ae9
. Mistake in documentation/error message?
https://github.com/android-ndk/ndk/issues/264
. 编译一个模块时出现undefined reference to `__android_log_print'
http://bbs.csdn.net/topics/360020076
4. Android Studio 之 JNI 开发详解
http://www.jianshu.com/p/bc2b46381d88
5. 向您的项目添加 C 和 C++ 代码
https://developer.android.com/studio/projects/add-native-code.html?hl=zh-cn
二、error:
. 错误1:
. 错误现象:
D:\zengjf\SourceCode\Android\android_app\Test>ndk-build
C:/Users/zengjf/AppData/Local/Android/Sdk/ndk-bundle/build//../build/core/build-binary.mk:687: Android NDK: Module zengjf depends on undefined modules: android_runtime nativehelper cutils utils log
C:/Users/zengjf/AppData/Local/Android/Sdk/ndk-bundle/build//../build/core/build-binary.mk:701: *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies) . Stop. D:\zengjf\SourceCode\Android\android_app\Test>
. 解决方法
. C:\Users\zengjf\AppData\Local\Android\Sdk\ndk-bundle\build\core\build-binary.mk
. 修改内容:
...
ifdef undefined_libs
$(call __ndk_warning,Module $(LOCAL_MODULE) depends on undefined modules: $(undefined_libs)) # https://github.com/android-ndk/ndk/issues/208
# ndk-build didn't used to fail the build for a missing dependency. This
# seems to have always been the behavior, so there's a good chance that
# there are builds out there that depend on this behavior (as of right now,
# anything using libc++ on ARM has this problem because of libunwind).
#
# By default we will abort in this situation because this is so completely
# broken. A user may define APP_ALLOW_MISSING_DEPS to "true" in their
# Application.mk or on the command line to revert to the old, broken
# behavior.
APP_ALLOW_MISSING_DEPS=true // add this line
ifneq ($(APP_ALLOW_MISSING_DEPS),true)
$(call __ndk_error,Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies))
endif
endif
...
. 错误2:
. 错误现象:
undefined references to `__android_log_print' follow
. 解决方法:
Android.mk文件中加入LOCAL_LDLIBS += -llog即可
使用Android Studio自带的NDK编译JNI的更多相关文章
- 安卓自动化测试:Android studio 自带的 Record Espresso Test || [ Appium & (Android studio || Python|| Eclipse ) ]
1.Android studio 自带的 Record Espresso Test https://developer.android.com/studio/test/espresso-test-r ...
- 运行Android Studio自带模拟器报:Guest isn't online after 7 second...
今天在运行Android Studio自带的手机模拟器时,出现如下异常情况 : 解决办法: 1.打开Android Virtue Device Manager,点击编辑选项 2.点击show Adva ...
- Android Studio 动态调试 apk 反编译出的 smali 代码
在信安大赛的准备过程中,主要通过 Android Studio 动态调试 apk 反编译出来的 smali 代码的方式来对我们分析的执行流程进行验证.该技巧的主要流程在此记录.以下过程使用 Andro ...
- android studio 2.2 使用cmake编译NDK
Android studio 2.2 已经进入beta版本,新功能添加众多,NDK编程也得到了简化.官方博客介绍.本文介绍如何使用新版android studio调用 c++代码,为了超级通俗易懂,例 ...
- android studio 1.0 开发 ndk 调用 c++ so库
一个没用过java和安卓的人使用android studio开发带c++ so库的安卓程序用例(以ndk的hello-jni为例),对于不熟悉java和安卓的人来说这个很花时间,希望通过这篇文章帮助跟 ...
- android studio使用CMake和NDK,实现应用自身被卸载时打开某一网址
实现应用自身被卸载时打开某一网址的c代码 MyActivity: public class MyActivity extends Activity { /** * Called when the ac ...
- 关于Android Studio中点9图的编译错误问题
Android中的点9图想必大家都非常熟悉了,能够指定背景图片的缩放区域和文本内容的显示区域,常见如QQ聊天界面的背景气泡这种文本内容不固定并需要适配的应用场景. 这里也给大家准备了一张图,详细介绍了 ...
- 在android studio中集成javah, ndk-build进行JNI开发
最近在搞一个android上控制LED灯闪烁的功能,用到了串口编程,搜索了一下,发现Google发布了一个demo,android-serialport-api.有现成的代码和APK,要想自己改JNI ...
- Android开发学习之路--NDK、JNI之初体验
好久没有更新博客了,最近一直在看一个仿微信项目,然后看源码并自己实现下,相信经过这个项目可以让自己了解一个项目中的代码以及种种需要注意的事项.不知不觉中博客已经快要40w访问量,而且排名也即将突破30 ...
随机推荐
- LeetCode:课程表【207】
LeetCode:课程表[207] 题目描述 现在你总共有 n 门课需要选,记为 0 到 n-1. 在选修某些课程之前需要一些先修课程. 例如,想要学习课程 0 ,你需要先完成课程 1 ,我们用一个匹 ...
- VS2013 IIS Express 无法显示站点目录列表
VS2013 默认使用IIS Express作为虚拟服务器,或许出于与安全考虑该版本的IIS Express默认关闭站点目录列表显示的功能,访问时会出现以下错误: 为了方便起见,我使用了全局设 ...
- display:inline与display:block——行内元素显示与块级元素显示
display:inline 的作用是设置对象做为行内元素显示,inline是内联对象的默认值(ps:内联对象就是不自动产生换行的元素,比如span) 而我们一般用的div是块级元素,默认displa ...
- jst格式化日期
jsp页面需引入fmt标签:<taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"> ...
- tomcat启动时出现There are no resources that can be added or removed from the server
对要部署的项目右键---Properties---Myeclipse---选中Dynamic Web Module 和 Java 应该是项目自己的setting文件夹下的描述信息和.project文件 ...
- fabric网关模式文件上传与执行
- SQL查询以某个字母开头
select * from a where left(a.name, 1)='H'; 或 select * from a where a.name REGEXP ''^(B|S)'';
- no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
1. 使用git克隆项目报错 $ git clone ssh://liuchao@192.168.7.32:29418/platform/Midou Cloning into 'Midou'... U ...
- spring整合redis配置
第一步:添加需要的jar包 <!-- redis --> <dependency> <groupId>redis.clients</groupId> & ...
- ThinkPHP关于模板的一些嵌套、IF判断使用
> ##### 前言,现在有一组数据(涉及到3个数据表,order订单表,order_process办理流程表,process_status流程描述表),根据当前订单,展示相应信息 1.办理流程 ...