User Tools

Site Tools


android:android-jni

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
android:android-jni [2010/11/04 13:52] – created percyandroid:android-jni [2011/03/16 12:44] percy
Line 1: Line 1:
 +====== Android JNI多线程相关 ======
 +  - http://android.wooyd.org/JNIExample/files/JNIExample.pdf
 +  - http://groups.google.com/group/android-ndk/browse_thread/thread/da092bd665ca9ff1
 +
 +
 ====== Android JNI相关 ====== ====== Android JNI相关 ======
 收集一些Android JNI的使用方法。 收集一些Android JNI的使用方法。
 ===== Android JNI介绍 ===== ===== Android JNI介绍 =====
   - Android JNI详述:参考http://hi.baidu.com/zhang_sg1984/blog/item/d0d7fcdd698916d58d1029af.html,讲得比较详细   - Android JNI详述:参考http://hi.baidu.com/zhang_sg1984/blog/item/d0d7fcdd698916d58d1029af.html,讲得比较详细
 +  - Android JNI 使用的数据结构JNINativeMethod详解:参考http://hi.baidu.com/caicry/blog/item/fd717a80cf98c7da9123d9da.html
 +  - JNI编程系列之高级篇:http://hi.baidu.com/caicry/blog/item/b0f51f51222f79828d54306b.html
 +  - JNI 返回结构体参数:http://andilyliao.javaeye.com/blog/496816 很不错的讲解结构体参数传递的教程。
 +  - NDK 应用及扩展介绍:http://wenku.baidu.com/view/361c9a2d2af90242a895e516.html,讲解了如何NDK中如何使用so文件。
 +  - JNI tutorial,老外写的教程,http://www.giamungo.com/JNI/JNI.html
 +  - JNI Examples for Android:http://android.wooyd.org/JNIExample/
  
 ====== NDK ====== ====== NDK ======
 +  * 教程
 +  - 【eoe特刊】第七期:Android NDK开发:http://www.eoeandroid.com/viewthread.php?tid=2718&extra=&highlight=&page=1
  
   * 实例:   * 实例:
   - Porting curl to Android - A success story with NDK 1.6:http://curl.haxx.se/mail/lib-2009-12/0071.html   - Porting curl to Android - A success story with NDK 1.6:http://curl.haxx.se/mail/lib-2009-12/0071.html
  
 +====== NDK Tips ======
 +  * NDK的默认Android.mk路径指定在project/jni目录下,如果我们需要将Android.mk提到上一级目录,需要修改文件NDK_ROOT\build\core\default-application.mk
 +  #APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/jni/Android.mk
 +  APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk
 +  
 +  * undefined reference to `wcstombs'
 +默认的NDK,在用到wcstombs函数时(已经include <stdlib.h>),编译会报错,在网上找了一下,是NDK的问题:http://blog.sina.com.cn/s/blog_4b650d650100m07j.html
 +可以在这里下载打过patch的版本,http://www.crystax.net/android/ndk-r4.php
 +
 +
 +  
 +
 +
 +====== Linux 网络编程 ======
 +  - Linux网络编程一步一步学+基础:http://blog.chinaunix.net/u1/48325/showart_413841.html
 +
 +====== NDK编译命令 ======
 +安装cygwin后,把cygwin/bin路径添加到PATH路径,执行下面的命令可以编译SO文件。这样就不需要每次都进入cygwin环境下再执行ndk-build。
 +
 +再简单一点将这行命令写成一个bat文件,这样只需要在cmd下面直接运行这个bat文件就行了。
 +<code>
 +bash D:\android\ndk\android-ndk-r4-windows\android-ndk-r4-windows\android-ndk-r4\ndk-build
 +</code>
 +====== NDK编译脚本For windows ======
 +简单写了一个脚本,调用ndk-build编译SO文件,
 +只支持两个参数
 +  nkdbuild build
 +  ndkbuild clean
 +[[android:android-jni:ndkbuild-bat-for-windows|Bat脚本for Windows]]
 +
 +===== NDK编译脚本For Linux ======
 +1.支持编译静态库
 +
 +2.解析Android.mk:支持指定编译后安装目录,支持编译前拷贝相关静态库到编译目录
 +
 +[[android:android-jni:ndkbuild-shell-for-linux|NDK Shell For Linux]]
 +
 +
 +====== ndk-gdb调试 ======
 +利用ndk-gdb可以直接调试native code.
 +
 +命令:
 +  bash /cygdrive/d/android/ndk/android-ndk-r4-windows/android-ndk-r4/ndk-gdb --start --force --verbose
 +
 +但在cygwin下调试时遇到了一个问题,
 +<code>
 +D:\workspace\DDTui>bash /cygdrive/d/android/ndk/android-ndk-r4-windows/android-ndk-r4/ndk-gdb
 +GNU gdb 6.6
 +Copyright (C) 2006 Free Software Foundation, Inc.
 +GDB is free software, covered by the GNU General Public License, and you are
 +welcome to change it and/or distribute copies of it under certain conditions.
 +Type "show copying" to see the conditions.
 +There is absolutely no warranty for GDB.  Type "show warranty" for details.
 +This GDB was configured as "--host=i686-pc-cygwin --target=arm-elf-linux".
 +/cygdrive/d/workspace/DDTui/bin/ndk/local/armeabi/app_process: No such file or directory.
 +</code>
 +找不到app_process文件,Google了一下,
 +找到类似的问题:http://code.google.com/p/android/issues/detail?id=8894
 +
 +方法是修改ndk-gdb:
 +<code>
 +# Get the app_server binary from the device
 +APP_PROCESS=$APP_OUT/app_process
 +#run adb pull /system/bin/app_process $APP_PROCESS
  
 +#Add by Jianqing Peng,20101122
 +if [ -s "${COMSPEC}" ] ; then
 +    run adb pull /system/bin/app_process  "`cygpath -w $APP_PROCESS`"
 +else
 +    run adb pull /system/bin/app_process  $APP_PROCESS
 +fi
  
 +</code>
  
 +====== native crash log分析 ======
 +[[android:android-jni:android-ndk-stacktrace-analyzer|native crash log分析]]
  
  
/var/www/dokuwiki/wiki/data/pages/android/android-jni.txt · Last modified: 2016/05/05 13:07 by 127.0.0.1