/**********************************************************************************
* 使用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. ruby安装神器rvm,你造吗?

    以前的一篇文章介绍过如何安装ruby,叫做:如何安装/更新ruby,安装cocoapods,为开发做好准备!(2016年12月07日更新内容) 文章中讲到的方法依然可行,但是该方法繁琐并且可能会出现各 ...

  2. 20145201《Java程序设计》第1次实验报告

    实验内容 一.命令行下java程序开发 1.建立Code目录,输入mkdir 20145201命令建立实验目录,并使用dir命令查看目录建立情况. 运行结果如图 2.进入实验目录,输入mkdir ex ...

  3. Spark 实现自定义对象sequenceFile方式存储,读写示例(scala编写)

    package com.fuge.bigdata.datahub.analysis import java.io.{DataInput, DataOutput} import com.fuge.big ...

  4. QT中没有byte

    QT里没有没有byte数据类型的 自己定义:#define byte unsigned char

  5. C++命名(自定义)

    1.自定义函数 void GetName(): 2.布尔型变量 BOOL ISOPEN:

  6. Android震动vibrator(马达)--系统到驱动的流程【转】

    本文转载自:https://blog.csdn.net/tianshiyalin/article/details/17136723 一.前言 本人刚学习安卓驱动开发,水平不能说菜,是根本没有水平,在这 ...

  7. thinkphp Composer安装指南

    1.首先我们去composer的官网下载composer,当然也可以用命令行的形势下下载,我是在windows安装的.https://www.phpcomposer.com/ 2.下载以后进行安装,一 ...

  8. scala mapPartitionsWithIndex函数的使用

    var rdd1=sc.makeRDD(Array((1,"A"),(2,"B"),(3,"C"),(4,"D")),2 ...

  9. 未能加载文件或程序集 Ninject.Web.Common, Version=3.2.0.0

    在Web MVC4中使用NuGet添加NInject.MVC4后,编译报了个警告: 发现同一依赖程序集的不同版本之间存在冲突 然后在运行时就运行到var kernel = new StandardKe ...

  10. excel 拖拽计算时,固定一个数

    $ 表示静态引用(也叫绝对引用)的意思.即固定引用的单元格的行或列. $A1即固定列为A,$A$2即固定引用为A列2行的单元格. A$3则只固定引用为第三行. 我们在使用excel拖拽计算时,常遇到这 ...