GithubHelp home page GithubHelp logo

lborsato / fat-aar-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kezong/fat-aar-android

0.0 1.0 0.0 386 KB

The solution of merging aar works with the gradle plugin's version of the development is 3.0.1 and higher.

License: Apache License 2.0

Java 19.25% Groovy 80.75%

fat-aar-android's Introduction

fat-aar-android

license Download

The solution of merging aar works with the android gradle plugin, the android plugin's version of the development is 3.0.1 and higher. (Tested in gradle plugin 3.0.1 - 3.4.1, and gradle 4.6 - 5.4.1)

Getting Started

Step 1: Apply plugin

Add snippet below to your root build script file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:xxx'
        classpath 'com.kezong:fat-aar:1.1.10'
    }
}

Add snippet below to the build.gradle of your android library:

apply plugin: 'com.kezong.fat-aar'

Step 2: Embed dependencies

change implementation or api to embed and add compileOnly while you want to embed the dependency in the library. Like this:

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')

    // java dependency
    embed project(path: ':lib-java', configuration:'default')
    compileOnly project(path: ':lib-java')

    // aar dependency
    embed project(path: ':lib-aar', configuration:'default')
    compileOnly project(path: ':lib-aar')

    // aar dependency
    embed project(path: ':lib-aar2', configuration:'default')
    compileOnly project(path: ':lib-aar2')
    
    // remote aar dependency
    embed 'com.facebook.fresco:fresco:1.11.0'
    compileOnly 'com.facebook.fresco:fresco:1.11.0'
    
    // local aar dependency, you need add the flatDir first.
    embed (name:'lib-aar-local2',ext:'aar')
    compileOnly (name:'lib-aar-local2',ext:'aar')

    // local aar dependency
    embed project(path: ':lib-aar-local', configuration:'default')
    compileOnly project(path: ':lib-aar-local')

    // other dependencies you don't want to embed in
    implementation 'com.android.support:appcompat-v7:27.1.1'
}

More usage see example.

About AAR File

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:

  • productFlavors
  • manifest merge
  • classes jar and external jars merge
  • res merge
  • assets merge
  • jni libs merge
  • proguard.txt merge
  • R.txt merge
  • R.class merge

Known Defects or Issues

  • Proguard note. Produce lots of(maybe) Note: duplicate definition of library class, while proguard is on. A workaround is to add -dontnote in proguard-rules.pro.
  • The overlay order of res merge is changed: Embedded dependency has higher priority than other dependencies.
  • 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:
    • consider using a prefix to each res Id, both in library res and aar dependencies if possible.
    • Adding "android.disableResourceValidation=true" to "gradle.properties" can do a trick to skip the exception, but is not recommended.

Thanks

fat-aar-android's People

Contributors

kezong avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.