Similarities and differences of ANDROID4.2.2NDK and source code development JNI

Source: Internet
Author: User

The method of output log information in the NDK and source code!

Ndk:
1. Include header file
#include <android/log.h>
2. ANDROID.MK contains the library
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
Above this must, otherwise appear error:undefined reference to ' __android_log_print '
Local_shared_libraries: = libdl\
Liblog\ #经测试在Eclipse中用NDK编译可有可无, no use! But in the source code must be him, so add it!
Libpre_appupgrade\
Libpre_apparea\
3. defined in your JNI file
#define LOGD (...) __android_log_print (android_log_debug,log_tag,__va_args__)//define LOGD type
#define Logi (...) __android_log_print (android_log_info,log_tag,__va_args__)//define Logi type
#define LOGW (...) __android_log_print (android_log_warn,log_tag,__va_args__)//define LOGW type
#define LOGE (...) __android_log_print (android_log_error,log_tag,__va_args__)//define Loge Type
#define LOGF (...) __android_log_print (android_log_fatal,log_tag,__va_args__)//define LOGF type

adnroid4.2 source has been added to the logd and so on a head,
#define ALOGD (...) __android_log_print (android_log_debug,log_tag,__va_args__)//define LOGD type
#define ALOGI (...) __android_log_print (android_log_info,log_tag,__va_args__)//define Logi type
#define ALOGW (...) __android_log_print (android_log_warn,log_tag,__va_args__)//define LOGW type
#define ALOGE (...) __android_log_print (android_log_error,log_tag,__va_args__)//define Loge Type
#define ALOGF (...) __android_log_print (android_log_fatal,log_tag,__va_args__)//define LOGF type

Note that if you do not want to define the above macros in each JNI file, the speculative method can be defined in: D:\android-ndk-r9d\platforms\android-19\arch-arm\usr\include\android\log.h! Of course, this compilation can only be used on your own machine ~

Source Code Development:
1. ANDROID.MK contains the library
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
Local_shared_libraries: = libdl\
liblog\//source code in the development of certain plus
Libpre_appupgrade\
Libpre_apparea\
2. Include header file # include <utils/Log.h>
3. Remember to include the header file of the library when you use it

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.