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
- Change the AAR file suffix name to ZIP and unzip
- Create a folder in the extracted directory
libs
, and then classes.jar
move all files and jni
folders under the libs
folder
- Copy the contents of a
proguard.txt
file to a proguard-project.txt
file in your project
- Create the file in the extracted directory with the
project.properties
following contents:target=android-22android.library=true
target
Value varies with the attribute value of the Android manifest.xml file in AAR targetSdkVersion
- 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