Android Code generation JAR Package

Source: Internet
Author: User

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

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.