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.