/**********************************************************************************
* 使用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的更多相关文章

  1. 安卓自动化测试: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 ...

  2. 运行Android Studio自带模拟器报:Guest isn't online after 7 second...

    今天在运行Android Studio自带的手机模拟器时,出现如下异常情况 : 解决办法: 1.打开Android Virtue Device Manager,点击编辑选项 2.点击show Adva ...

  3. Android Studio 动态调试 apk 反编译出的 smali 代码

    在信安大赛的准备过程中,主要通过 Android Studio 动态调试 apk 反编译出来的 smali 代码的方式来对我们分析的执行流程进行验证.该技巧的主要流程在此记录.以下过程使用 Andro ...

  4. android studio 2.2 使用cmake编译NDK

    Android studio 2.2 已经进入beta版本,新功能添加众多,NDK编程也得到了简化.官方博客介绍.本文介绍如何使用新版android studio调用 c++代码,为了超级通俗易懂,例 ...

  5. android studio 1.0 开发 ndk 调用 c++ so库

    一个没用过java和安卓的人使用android studio开发带c++ so库的安卓程序用例(以ndk的hello-jni为例),对于不熟悉java和安卓的人来说这个很花时间,希望通过这篇文章帮助跟 ...

  6. android studio使用CMake和NDK,实现应用自身被卸载时打开某一网址

    实现应用自身被卸载时打开某一网址的c代码 MyActivity: public class MyActivity extends Activity { /** * Called when the ac ...

  7. 关于Android Studio中点9图的编译错误问题

    Android中的点9图想必大家都非常熟悉了,能够指定背景图片的缩放区域和文本内容的显示区域,常见如QQ聊天界面的背景气泡这种文本内容不固定并需要适配的应用场景. 这里也给大家准备了一张图,详细介绍了 ...

  8. 在android studio中集成javah, ndk-build进行JNI开发

    最近在搞一个android上控制LED灯闪烁的功能,用到了串口编程,搜索了一下,发现Google发布了一个demo,android-serialport-api.有现成的代码和APK,要想自己改JNI ...

  9. Android开发学习之路--NDK、JNI之初体验

    好久没有更新博客了,最近一直在看一个仿微信项目,然后看源码并自己实现下,相信经过这个项目可以让自己了解一个项目中的代码以及种种需要注意的事项.不知不觉中博客已经快要40w访问量,而且排名也即将突破30 ...

随机推荐

  1. ocx的容器调试和ie调试

    1 容器调试 1.1 F5,选择ActivesX Control Test Containor 1.2 ok--ok,选择工具栏的new control 1.3 在Insert Control内选择你 ...

  2. pt-osc原理

    pt-osc原理 1.检查设置环境 测试db是否可连通,并且验证database是否存在 SET SESSION innodb_lock_wait_timeout=1 //InnoDB事务等待行锁的超 ...

  3. Vim:gvim安装配置(windows)

    Vim:gvim安装配置(windows) 一.gvim的特点: vim要求全部键盘操作,而gvim可以使用鼠标进行可视化操作,即gvim是vim的图形化界面: 二.gvim安装: 下载地址:http ...

  4. 纯CSS3滑动开关按钮

    在线演示 本地下载

  5. github Git-fork-别人的项目后更新代码的方法

     用github还处于菜的阶段,遇到问题简单记录.   举个例子,需要 fork 这个项目 https://github.com/tarobjtu/WebFundamentals.git 点击 for ...

  6. c语言的按位运算符

    & 按位与 | 按位或 ^ 按位异或 1. 按位与运算 按位与运算符"&"是双目运算符.其功能是参与运算的两数各对应的二进位相与.只有对应的两个二进位均为1时,结果 ...

  7. Lily hbase indexer搭建配置概要文档

    1.solrcloud搭建好2.hbase-solr-indexer服务开启3.确定hbase中的对应的表开启replication功能 create '} // 1表示开启replication 已 ...

  8. mkfs.ext4 磁盘分区

    在linux上格式化一个磁盘分区时,出现如下错误 root@d:~# mkfs.ext4 /dev/sdb1 mke2fs 1.41.12 (11-May-2015) mkfs.ext4: inode ...

  9. 简单的aop实现日志打印(切入点表达式)

    Spring中可以使用注解或XML文件配置的方式实现AOP. 1.导入jar包 com.springsource.net.sf.cglib -2.2.0.jar com.springsource.or ...

  10. MySQL for Mac 5.7.x 版本忘记密码修改root密码

    1.安装mysql 2.命名别名: vim ~/.bash_profile alias mysql=/usr/local/mysql/bin/mysql alias mysqladmin=/usr/l ...