protobuf源码NDK编译配置 假设工程结构如下: protobuf-build |-jni |- Android.mk |- Application.mk |- google |-protobuf Android.mk LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) CC_LITE_SRC_FILES := \ google/protobuf/arena.cc \ google/protobuf/arenastring.cc \ google/protobuf/extension_set.cc \ google/protobuf/generated_message_table_driven_lite.cc \ google/protobuf/generated_message_util.cc \ google/protobuf/io/coded_stream.cc \ google/protobuf/io/zero_copy_stream.cc \ google/protobuf/io/zero_copy_stream_impl_lite.cc \ google/protobuf/message_lite.cc \ google/protobuf/repeated_field.cc \ google/protobuf/stubs/atomicops_internals_x86_gcc.cc \ google/protobuf/stubs/atomicops_internals_x86_msvc.cc \ google/protobuf/stubs/bytestream.cc \ google/protobuf/stubs/common.cc \ google/protobuf/stubs/int128.cc \ google/protobuf/stubs/io_win32.cc \ google/protobuf/stubs/once.cc \ google/protobuf/stubs/status.cc \ google/protobuf/stubs/statusor.cc \ google/protobuf/stubs/stringpiece.cc \ google/protobuf/stubs/stringprintf.cc \ google/protobuf/stubs/structurally_valid.cc \ google/protobuf/stubs/strutil.cc \ google/protobuf/stubs/time.cc \ google/protobuf/wire_format_lite.

Continue reading

引用静态库头文件: LOCAL_C_INCLUDES += ../include/ 引用静态库: LOCAL_LDLIBS += ../lib/libMyBoostLib.a Android.mk: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := helloJNI LOCAL_SRC_FILES := mainActivity.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc/ LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ -lMyLibrary include $(BUILD_SHARED_LIBRARY) Include prebuilt static library https://stackoverflow.com/questions/18983037/include-prebuilt-static-library 故兵无常势,水无常形。能因敌变化而取胜者,谓之神。故五行无常胜,四时无常位,日有短长,月有死生。---《孙子兵法·虚实篇》

Continue reading

原文:https://blog.csdn.net/tommy_wxie/article/details/12841735 1.将ndk中的arm-linux-androideabi-addr2line可执行文件的路径加入配置文件~/.bashrc中,例如: export PATH=$PATH:~/dlna/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin 2.使配置生效: source ~/.bashrc 3.使用工具。例如: arm-linux-androideabi-addr2line -C -f -e ~/workspace/DLNA/libs/armeabi/libctrlpt.so 0003deb4 其中,0003deb4为堆栈信息中pc的值。 android应用崩溃的调试方法 有两种方法可以分析 crash 的堆栈信息 1,google提供了一个python脚本,可以从 https://github.com/maxme/android-ndk-stacktrace-analyzer 下载这个python脚本,然后使用 adb logcat -d > logfile 导出 crash 的log,使用 arm-eabi-objdump 位于build/prebuilt/linux-x86/arm-eabi-4.2.1/bin下面把so或exe转换成汇编代码,如:arm-eabi-objdump -S mylib.so > mylib.asm,使用脚本 python parse_stack.py <asm-file> <logcat-file> 2,直接使用NDK下面的arm-linux-androideabi-addr2line (D:\android-ndk-r8\toolchains\arm-linux- androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-addr2line.exe) 例如: arm-linux-androideabi-addr2line -C -f -e libxxx.so 0x#####(address) 出现 ??:0 , 没法展示源代码行数的问题 在Android.mk 文件中: LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS -Wl,-Map=test.map -g 补充2个编译参数 -Wl,-Map=test.map -g .

Continue reading

Protobuf源码与protoc生成代码编译成一个静态库 工程结构: MyProj |-jni |- Android.mk |- Application.mk |- google |- protobuf |- io |- stubs |- proto_gen_src 其中,google为protobuf的源码;proto_gen_src为protoc生成的代码,即:*.pb.cc。 Android.mk LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) CC_LITE_SRC_FILES := \ google/protobuf/stubs/common.cc \ google/protobuf/stubs/once.cc \ google/protobuf/extension_set.cc \ google/protobuf/generated_message_util.cc \ google/protobuf/message_lite.cc \ google/protobuf/repeated_field.cc \ google/protobuf/wire_format_lite.cc \ google/protobuf/io/coded_stream.cc \ google/protobuf/io/zero_copy_stream.cc \ google/protobuf/io/zero_copy_stream_impl_lite.cc # C++ full library # ======================================================= #include $(CLEAR_VARS) LOCAL_MODULE := MyProj.ndk LOCAL_MODULE_TAGS := optional LOCAL_CPP_EXTENSION := .cc #protobuf源码目录 LOCAL_SRC_FILES += \ $(CC_LITE_SRC_FILES) #protoc生成代码的目录 MY_CPP_LIST := $(wildcard $(LOCAL_PATH)/proto_gen_src/*.

Continue reading

如果你的android app出现以下两种错误log提示,并不影响你的app运行,如果你的app崩溃,可以忽略下面两种log。 10-17 16:59:29.263: E/ExtMediaPlayer-JNI(22104): env->IsInstanceOf fails 10-17 16:59:29.263: E/MediaPlayer-JNI(22104): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0 10-17 16:59:29.263: E/ExtMediaPlayer-JNI(22104): env->IsInstanceOf fails 10-17 16:59:29.263: E/MediaPlayer-JNI(22104): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0 10-18 00:25:40.894: E/MediaPlayer(28634): stop called in state 1 10-18 00:25:40.894: E/MediaPlayer(28634): error (-38, 0) 10-18 00:25:40.903: E/MediaPlayer(28634): Error (-38,0) 这两个错误log的具体原因不清楚,第一个貌似和权限相关。

Continue reading

android NDK编译代码时,命令行提示错误: jni/Android.mk:21: *** missing separator. Stop. 原因有以下几点: 1,$符号之前必须有一个空格,不能跟前面的字符连在一起。如果$是该行的第一个字符,前面可以不用空格。 例子(正常): LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) 错误写法: LOCAL_PATH :=$(call my-dir) include$(CLEAR_VARS) 2,每行结尾处不能有空格。 例子(正常): COMPILER_SRC_FILES := \ 错误写法: COMPILER_SRC_FILES := \

Continue reading

NDK 1.2之后的版本已修复此bug,1.2及1.2之前的版本存在这个问题。但1.2之后的版本不再支持GCC。 原文: http://boguscoder.blogspot.jp/2013/08/android-ndk-stl-linking-issues-bug.html ld.exe: libmoduleA.a(moduleA.o): in function std::priv::_String_base>::_M_allocate_block(unsigned int):/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158: error: undefined reference to ‘std::_node_alloc::_M_allocate(unsigned int&)’ ld.exe: libmoduleA.a(moduleA.o): in function std::priv::_String_base>::_M_allocate_block(unsigned int):/sources/cxx-stl/stlport/stlport/stl/_string.c:600: error: undefined reference to ‘std:stl_throw_length_error(char const*)’ ld.exe: libmoduleA.a(moduleA.o): in function functionA():/sources/cxx-stl/stlport/stlport/stl/_alloc.h:161: error: undefined reference to ‘std::node_alloc::_M_deallocate(void*, unsigned int)‘collect2: ld returned 1 exit status Android.mk中添加库libstlport_static.a: LOCAL_LDLIBS := -lmoduleA \ <NDK_PATH>/libstlport_static.a 如果是UE4工程编译Android,到android-ndk-r10e\sources\cxx-stl\stlport\libs\armeabi\下拷贝一个libstlport_static.a到你工程的库文件目录下即可。

Continue reading

http://blog.marcingil.com/android-ndk-link-static-library-to-your-jni-library/ When you’re developing an application that needs to use a custom, native precompiled library (the .a file) together with your gluing JNI interface maybe you’re wondering how to link it. It’s fairly simple and you can even make it target architecture aware (separate precompiled libraries for arm, arm-v7a, x86). In your module (I’m using Android Studio) you should have a jnidirectory, like this: project / + module + src + main + jni # JNI source files here and other native sources here | Android.

Continue reading

Author's picture

Neil Wang

久长唯有品格

To Be Marvelous

Yichang·Hubei