"Go" "Android" 1 minutes without changing any code use AAR in eclipse

Source: Internet
Author: User

Original: Https://www.jianshu.com/p/ccf306e08d5b?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io

AAR is a library file format that Google has launched specifically for Android Studio for easy sharing and use
Android Library Project

Eclipse ADT, which was abandoned by Google, has no way to use AAR as with jars, but we can use the files in AAR to quickly create an Eclipse Library project to use

The Eclipse Library, AAR
    1. Change the AAR file suffix name to ZIP and unzip
    2. Create a folder in the extracted directory libs , and then classes.jar move all files and jni folders under the libs folder
    3. Copy the contents of a proguard.txt file to a proguard-project.txt file in your project
    4. Create the file in the extracted directory with the project.properties following contents:
      target=android-22android.library=true
      targetValue varies with the attribute value of the Android manifest.xml file in AAR targetSdkVersion
    5. Delete aapt and jni folders as well as R.txt and proguard.txt files

Now that an Eclipse Library project has been built, just open the Eclipse Import project and configure the project to reference it in your project.

FAQ:
    • If there is activity in the library or the other four components cannot be found in the runtime (activitynotfoundexception), the asset resource cannot be found, the jar or so cannot be found, please refer to the "Android" Eclipse reference Common exceptions at the library
    • The activity report java.lang.NoClassDefFoundError: *.Activity is unusual, usually because the activity in the AAR inherits or implements a class or interface in another AAR, but you do not have the dependency to import the AAR, which causes the activity in the AAR to not be instantiated, and the solution is to import all needed Depending on what you need to rely on you find AAR's pom file to view or decompile the corresponding error Class View

Android's official ADT plugin looks good when referencing the library project, but there are many pits

1. Asset resources in the library are not automatically merged

The ADT plugin does not automatically merge the asset resources in the library into your project, so you need to copy them manually

2. androidmanifest files in library are not automatically merged

If you refer to a library that contains four components, you will never be able to start the four components contained in the library without any additional configuration (such as throwing activitynotfoundexception when starting activit), Because you need to configure ADT in your project's project.properties file to merge the Androidmanifest files in the library as follows:
Manifestmerger.enabled=true
此属性需要 ADT 17 以上版本

3. The jar package or so file in the Libs directory in the library will not be imported automatically

To solve this problem, you only need to upgrade ADT to 17 or later.

Although most of the Android Studio has been developed with Android, some people still use Eclipse
, like most game developers are mostly using Eclipse when integrating some third-party SDKs, so these issues still have a record value.


Floating prawns
Links: https://www.jianshu.com/p/ccf306e08d5b
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

"Go" "Android" 1 minutes without changing any code use AAR in eclipse

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.