Follow the ghost Brother to learn how to modify so. I. Preparation, so

Source: Internet
Author: User

Follow the ghost Brother to learn how to modify so. I. Preparation, so

Figure/story

Let's talk about the importance of so modification. We all know the importance of writing so files from the beginning, analyzing so files, modifying so files, and planning to create a series of tutorials. Of course, we mainly want to see the time allowed.


For android sdk configuration and ndk environment download, please google it on your own.


You won't go over the wall, or use tools. You can skip this article.


0x1: Create an android Project




0x2: Compile the code and method definition for calling so



Create a JniGg. java file in the same directory of MainActivity. java to call the so



0x3: generate a file header. h file

In this directory, we can see that the class file we have compiled is automatically compiled by eclipse.



Everything is compiled normally, so now we will go back to the project root directory:



Then switch to this directory on the command line:




Now we use the following command: javah-classpath bin/classes-d jni com. ggndktest1.JniGg





No error is reported and the. h file is compiled successfully.


The bin/classes is the one that needs to be noted above, because the compiled classes directory on my computer looks like this. Refer to the picture in the above file directory, and the/classes is not required on some computers. In Eclipse, right-click the project and refresh it. You can see the following:





0x4: Write c code





Create file in the jni directory, gg-jni.c look at the code, it knows what it means



Then the Android. mk file is compiled.





0x5: generate the so file





Switch to the project root directory and run ndk-build directly. Note that environment variables must be configured for ndk-build. You can search for configuration methods by yourself.



0x6: android call code




Create a new TextView and display the strings in so. Then run our test code:




Related attachments and documents:

Http://pan.baidu.com/s/1pJ2Y047



The article is also submitted to www.pd521.com for initial release. Please indicate the source for reprinting.





Related Article

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.