Detailed example of Android JNI debugging and printing char array

Detailed example of Android JNI debugging and printing char array

preface:

In Android development, it is sometimes necessary to print a string in binary format with JNI. The more friendly output format is a four column, eight column and sixteen column matrix format. Similarly, the following error occurs when deleting a wild pointer:

Google's engineers are very sophisticated. Below the code around PC is a five column matrix, which is highly readable. In recent projects, encryption algorithms need to be used, so printing matrix during debugging is a good choice. Due to the interface provided by Android JNI

__ android_ log_ write

One line will be printed every time, which is not as convenient as printf. Therefore, it is necessary to__ android_ log_ Write for secondary packaging. The idea is to first apply for a space, then store the printed content in the memory, and finally log output.

The specific codes are as follows:

Test call code

Output results

Note: remember to add it in android.mk when using < Android / log. H >

If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>