Frontier: Sometimes our Android project will have the core algorithm or code, generally this situation will be the algorithm (CPP files, etc.) into so files, the code to organize into a jar or AAR package; Today we will discuss how to make the algorithm into so files, how to make the key code into a jar package.
how to encapsulate the algorithm into so files? First we know that the algorithm is written in C, here we use JNI to complete the project and the algorithm of the value (the subsequent addition of JNI usage), using CMake to compile the so file (subsequent supplement CMake usage), the steps are as follows:
1. If there is no CPP folder, build one yourself, put the algorithm file under the CPP file, then create the CPP file, write the method of communication with JNI and algorithm;
2. Select this item and select build-->rebuildproject; in the menu bar
3. View the files under the Build-->intermediates-->cmake-->debug-->obj folder of the project, these are the resulting so libraries:
How to make the key code into a jar package? the first thing to understand is the application scenario for Jar and AAR, which is not explained here, and then we'll discuss how to make a jar package:
1. Use MyEclipse to develop software, new Java project, copy key code to SRC, key code includes package and class;
2. Hit the JAR: Project Right-click Export-->jar file-->next-->
3. Successfully hit into jar, sometimes need to confuse, next is the most basic confusion Jar method, first download Proguard file (I use proguard5.1), double-click Projuardgui.bat;
After double-click:
4. Set the parameter 1:
5. The classes or interfaces that are generally not confused are to be exposed to the user to be called:
If there is an interface, then add the interface configuration
6. Start confusing:
Confuse success, go to the designated location to find the jar is OK
7. View the native method, get the confusing package name and method name, modify it in the CPP file of the code JNI, and then repackage the so file;
So even if completed, perhaps not too detailed, but hope to bring help to everyone, if there is not the right place, but also look forward to enlighten, common progress!
Android code generation jar package