ndk_hello-jni/two-libs/native-activity





  Ndk_Demo:  
  hello-jni;two-libs;native-activity;

  hello-jni总结:java调lib内容;


  two-libs总结:lib2调用了lib1里面内容:
#Android.mk,生成两个.so文件,它们之间没有任何关系,都是为java提供接口。
  LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)
  LOCAL_MODULE    := hello-jni
  LOCAL_SRC_FILES := hello-jni.c
  include $(BUILD_SHARED_LIBRARY)
  #second lib.
  include $(CLEAR_VARS)
  LOCAL_MODULE    := hello-jni222
  LOCAL_SRC_FILES := hello-jni222.c
  include $(BUILD_SHARED_LIBRARY)
#Android.mk,生成一个.so文件,该so文件调用另一个.so文件。
  include $(CLEAR_VARS)
  LOCAL_MODULE    := libtwolib-first
  LOCAL_SRC_FILES := first.c
  include $(BUILD_STATIC_LIBRARY)
  #second lib, which will depend on and include the first one
  include $(CLEAR_VARS)
  LOCAL_MODULE    := libtwolib-second
  LOCAL_SRC_FILES := second.c
  LOCAL_STATIC_LIBRARIES := libtwolib-first
  include $(BUILD_SHARED_LIBRARY)

  native-activity总结:主要是利用了SurfaceView,绘制过程交给其他线程来完成。  
  public class NativeActivity extends Activity implements SurfaceHolder.Callback2,InputQueue.Callback,OnGlobalLayoutListener{ *** }
  NativeActivity:Convenience for implementing an activity that will be implemented purely in native code.you can simply declare it in your manifest, and use the NDK APIs from there.
  NDK,刚开始学,相应的C/C++代码如何编写,函数名如何定义? 可以利用javah这个工具生成相应的.h文件,然后根据这个.h文件编写相应的C/C++代码。
  $javah -classpath bin -d jni com.example.hellojni.HelloJni
  用windows下的eclipse配置ndk-build会出现Cannot run program "ndk-build": Launching failed的问题,终于解决了。在工程--->properties--->C/C++ Build--->Builder Settings中Build_command中的ndk-build改为ndk-build.cmd
  error: format not a string literal and no format arguments [-Werror=format-security];  在Application.mk里添加APP_CPPFLAGS += -Wno-error=format-security
  undefined reference to '__android_log_print';  在Android.mk里添加 LOCAL_LDLIBS:=-llog




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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值