使用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 ...
随机推荐
- php内存管理机制、垃圾回收机制
一.内存管理机制 先看一段代码: <?php //内存管理机制 var_dump(memory_get_usage());//获取内存方法,加上true返回实际内存,不加则返回表现内存 $a = ...
- Microservice 概念
一天我司招财猫姐(HR 大人)问我,你给我解释一下 Microservice 是什么吧.故成此文.一切都是从一个创业公司开始的. 故事 最近的创业潮非常火爆,我禁不住诱惑也掺和了进去,创建了一家公司. ...
- LAMP脚本
A goal is a dream with a deadline. Much effort, much prosperity. 环境:CentOS release 6.5 2.6.32-431.e ...
- SpringBoot 定义通过字段验证
第一步:定义ValidationResult类 public class ValidationResult { // 校验结果是否有错 private boolean hasErrors = fals ...
- autofac.webapi2
quick start https://autofaccn.readthedocs.io/en/latest/integration/webapi.html#quick-start To get Au ...
- Apache HTTP Server——官网下载
Windows版 Apache 2.4.x OpenSSL 1.0.2 VC14 ——Apache 2.4.34 x64(注:x64就是64位,x86就是32位) https://www.apach ...
- scala学习手记7 - 运算符重载
从语法上来说scala是没有运算符的.之前的一节里也曾提到过scala的运算符实际上是方法名,如1 + 2实际上就是1.+(2).我们可以将之视为运算符,是因为scala的一个特性:如果方法的参数小于 ...
- git 分支管理 (转自廖雪峰的git教程)
在版本回退里,你已经知道,每次提交,Git都把它们串成一条时间线,这条时间线就是一个分支.截止到目前,只有一条时间线,在Git里,这个分支叫主分支,即master分支.HEAD严格来说不是指向提交,而 ...
- D3.js学习笔记(一)——DOM上的数据绑定
开始学习D3.js,网上没有找到很满意的中文教程,但是发现了一个很好的英文教程,讲解的非常详细.从一个初始简单的HTML网页开始,逐步加入D3.js的应用,几乎是逐句讲解.学习的时候,就顺便翻译成中文 ...
- HTML5 canvas之基础篇(一)
一.检测浏览器是否支持canvas if( !canvas || !canvas.getContext){ return; } 也可以使用modernizr.js库,Modernizr是一个易用的轻量 ...