android生成so文件流程,android NDK 生成so 文件流程-ecplice

1:生成jni目录

首先说一句网上,大部分博客这么写的:打开控制台,进入项目目录,运行

javah -classpath bin/classes -d jni com.example.hellojni.MainAcitivity

我只想问一句,这些代码您亲自运行成功了吗?您这么写出来责任心何在?

这么写你会遇到这个错误。

c8725ec584e7ff2a623f80d076718414.png

实际上可以这么写:

1: javah -classpath src -d jni com.itg.jni.ImageBlur

或写入android.jar的路径直接执行

2:javah -classpath C:\project\Android\adt-bundle-windows-x86_64-20131030\sdk\platforms\android-22\android.jar;bin/classes -d jni com.itg.jni.ImageBlur

然后你会在项目中得到jni文件夹及.h的文件

然后编写C文件。

3:右键jni文件 添加Android.mk文件

写入配置

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := JNI_ImageBlur

LOCAL_SRC_FILES := com_itg_jni_ImageBlur.cpp

LOCAL_LDLIBS := -ljnigraphics -llog

include $(BUILD_SHARED_LIBRARY)

LOCAL_LDLIBS := -ljnigraphics -llog 这一句如果没用到BitMap不要添加。

我的需求是,操作图片 如果没有这句汇报

在编译jni的cpp文件时出现:

jni/NDKtest.cpp:21: error: undefined reference to 'AndroidBitmap_getInfo'

jni/NDKtest.cpp:22: error: undefined reference to '__android_log_print'

jni/NDKtest.cpp:26: error: undefined reference to '__android_log_print'

jni/NDKtest.cpp:29: error: undefined reference to 'AndroidBitmap_lockPixels'

jni/NDKtest.cpp:30: error: undefined reference to '__android_log_print'

jni/NDKtest.cpp:39: error: undefined reference to 'AndroidBitmap_unlockPixels'

collect2.exe: error: ld returned 1 exit status

make.exe: *** [obj/local/armeabi/libNDKtest.so] Error 1

2 下载NDK(Native Development Kit)

80ba1614752690938c5ca237599c2644.png

2:选中要生成so 文件的项目选择Property-->Builders-->New

01b6f2631b41f39a9e722fed5c9f2da1.png

设置Location,添加 ndk-build.cmd

设置working Directory 选择项目中jni目录

设置build Options

勾选如图所示

0b8011f7fc4893a232a67d01103f6ec9.png

设置Specify Resources,直接选择jni文件夹即可。完毕,保存,ecplice会自动在armeabi文件夹下生成so文件

f216c8ab92c44f1ebaee9981c3f161b3.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值