The solution of merging aar works with AGP 3.0
and higher. (Tested in AGP 3.0 - 4.2.0, and Gradle 4.9 - 6.8)
JCenter services will be deprecated on May 1st 2021, if you are using the version in JCenter, it is recommended to rename the group name and switch to Maven Central. Like this:'com.kezong:fat-aar:x.x.x' => 'com.github.kezong:fat-aar:x.x.x'
For Maven Central (The lastest release is available on Maven Central):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.kezong:fat-aar:1.3.6'
}
}
For JCenter (Deprecated, before 1.3.4):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.kezong:fat-aar:1.3.3'
}
}
Add snippet below to the build.gradle
of your main android library:
apply plugin: 'com.kezong.fat-aar'
Declare embed
for the dependencies you want to merge in build.gradle
.
The usage is similar to implementation
, like this:
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// java dependency
embed project(path: ':lib-java', configuration: 'default')
// aar dependency
embed project(path: ':lib-aar', configuration: 'default')
// aar dependency
embed project(path: ':lib-aar2', configuration: 'default')
// local full aar dependency, just build in flavor1
flavor1Embed project(path: ':lib-aar-local', configuration: 'default')
// local full aar dependency, just build in debug
debugEmbed(name: 'lib-aar-local2', ext: 'aar')
// remote jar dependency
embed 'com.google.guava:guava:20.0'
// remote aar dependency
embed 'com.facebook.fresco:fresco:1.12.0'
// don't want to embed in
implementation('androidx.appcompat:appcompat:1.2.0')
}
If you want to include local transitive dependencies in final artifact, you must add embed
for transitive dependencies in your main library.
For example, mainLib depend on subLib1, subLib1 depend on subLib2, If you want include all dependencies in the final artifact, you must add embed
for subLib1 and subLib2 in mainLib build.gradle
If you want to inlcude all of the remote transitive dependencies which are in POM file, you need change the transitive
value to true in your build.gradle
, like this:
fataar {
/**
* If transitive is true, local jar module and remote library's dependencies will be embed. (local aar module does not support)
* If transitive is false, just embed first level dependency
* Default value is false
* @since 1.3.0
*/
transitive = true
}
If you change the transitive value to true,and want to ignore a dependency in its POM file, you can add exclude keywords, like this:
embed('com.facebook.fresco:fresco:1.11.0') {
// exclude all dependencies
transitive = false
// exclude any group or module
exclude(group:'com.facebook.soloader', module:'soloader')
}
More usage see example.
AAR is a file format for android library.The file itself is a zip file that containing useful stuff in android.See anatomy of an aar file here.
support list for now:
Version | Gradle Plugin | Gradle |
---|---|---|
1.0.1 | 3.1.0 - 3.2.1 | 4.4 - 6.0 |
1.1.6 | 3.1.0 - 3.4.1 | 4.4 - 6.0 |
1.1.10 | 3.0.0 - 3.4.1 | 4.1 - 6.0 |
1.2.6 | 3.0.0 - 3.5.0 | 4.1 - 6.0 |
1.2.8 | 3.0.0 - 3.5.9 | 4.1 - 6.8 |
1.2.11 - 1.2.14 | 3.0.0 - 3.6.9 | 4.1 - 6.8 |
1.2.15 - 1.2.16 | 3.0.0 - 4.0.2 | 4.1 - 6.8 |
1.2.17 | 3.0.0 - 4.0.2 | 4.9 - 6.8 |
1.2.18+ | 3.0.0 - 4.1.0 | 4.9 - 6.8 |
1.3.+ | 3.0.0 - 4.1.0 | 4.9 - 6.8 |
1.3.4 - 1.3.5 | 3.0.0 - 4.1.0 | 4.9+ |
1.3.6 | 3.0.0 - 4.2.0 | 4.9+ |
The following link which version of Gradle is required for each version of the Android Gradle plugin. For the best performance, you should use the latest possible version of both Gradle and the plugin.
Plugin version and Required Gradle version
Application cannot directly rely on embedded project: application cannot directly rely on your embedded project. It must rely on the AAR file compiled by your embedded project
embed
in the main library project when you choose to package aar. When you need to run the app directly, you can use implementation
or api
Res merge conflicts. If the library res folder and embedded dependencies res have the same res Id(mostly string/app_name
). A duplicate resources build exception will be thrown. To avoid res conflicts:
android.disableResourceValidation=true
to gradle.properties
can do a trick to skip the exception.Proguard
minifyEnabled
is set to true, classes not referenced in the project will be filtered according to Proguard rules during compile, resulting in ClassNotFound during app compile.Most AAR is SDK that provide interfaces. It is recommended that you carefully comb Proguard files and add keep rules./*** This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as
fat-aar介绍 fat-aar地址:github.com/adwiv/andro… Gradle script that allows you to merge and embed dependencies in generated aar file. 复制代码 根据官方介绍,fat-aar是一个允许你合并和嵌入依赖关系到生成的aar文件的gradle脚本,通俗点说,fat-aar的主要工作就
使用fat-aar(com.kezong.fat-aar) 配合flutter package项目生成nativie项目中间件aar 1,.android项目内跟目录的build.gradle 添加如下: dependencies { classpath 'com.android.tools.build:gradle:3.2.1' // classpath "com.mobbeel.plugin:
最近在打包 aar 时,总是遇到问题。尤其是在多依赖库时,副 module 的引用库一直找不到资源,这是因为正常的依赖关系是可以构建的,但如果打包成 aar 的话是不会把相关 module 里依赖的第三方 aar/ jar 管理起来,这需要另外一种方式进行 aar 构建。 相信大家都应该知道 android-fat-aar 这个脚本库,但是这个库早在 17 年的时候就不维护了。并且有很多地方需要关
fat-aar.gradle是什么? 在做android应用程序开发时,我们一般都会构建多个模块,来达到解耦的目的,但是有的需求是需要我们提供一个依赖库给外部使用,这时候就遇到一个问题:多个module确实达到了解耦的目的,同时也意味着对外提供依赖库时要提供多个aar,一个依赖module对应一个aar。fat-aar 的功能简单来说就是让你能够合并和插入各种依赖到一个aar中。 项目地址:Git
全栈式Php 5.3微型框架, 自带auth, orm(sql/mongodb), 验证码,图表,feed, smtp等一系列功能
Git-fat 是 Git 文件处理组件,可以简单的处理一些比较大的文件,而无需提交到Git。同时,Git-fat 也支持 rsync 同步处理。 特点 源存储库的副本小而又快,因为没有二进制文件被传输,但具有完整的元数据和增量检索功能(git clone --depth具有有限的粒度并将元数据耦合到内容) git-fat 支持大型二进制文件和传统版本文件的相同工作流程,但在内部分别管理“胖”文件
Fat Free CRM 是一个基于 Ruby 语言和 Rails 框架开发的客户关系管理平台,也就是我们所说的 CRM 系统。 Fat Free CRM 的界面非常精致而漂亮,如下图所示(点击查看大图)
我有一个android gradle项目结构,看起来像这样 < li >模块1-aar < li >模块2-aar < li>testapp-apk 关键事实 模块2 aar取决于模块1 aar。 testapp apk取决于模块2 aar。 JDK11 Gradle 7.4.2 Androidgradle插件7.1.3 没有javadocs、gpg、签名或发布,一切都构建得很好。App运行,一切
我看到过许多开发人员发布的问题(Android Studio将2.AAR合并为一个或其他),但我还没有看到一个明确的答复,使我能够创建一个包含一个或多个AAR或jar的AAR(我可以使用jar,因为我不需要共享任何资源;只需要共享类)。以下是我的图书馆项目的应用程序分级: 我读过关于传递依赖的文章,但我找不到一个可以帮助解决我的情况的示例实现。
问题内容: 我听说有人说他们创建了一个fat JAR并部署了它。它们实际上是什么意思? 问题答案: fat jar是jar,其中包含项目所依赖的所有库中的类,当然还有当前项目的类。 在不同的构建系统中,fat jar的创建方式有所不同,例如,在Gradle中,可以使用(指令)创建胖子罐: 在Maven中,是通过以下方式完成的(在设置了常规jar之后):