Giter Site home page Giter Site logo

gmazzo / gradle-apklib-plugin Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 2.0 84 KB

An Android-Gradle plugin for generate DEX classes and a APK from a Library module.

Groovy 36.29% Kotlin 63.71%
android gradle library dex aar apk kotlin kotlin-android dagger2 dagger2-android gradle-plugin classloader serviceprovider

gradle-apklib-plugin's Introduction

gradle-apklib-plugin

An Android-Gradle plugin for generate DEX classes and a APK from a Library module.

Plugins Site

Why?

Well, if you reach this page, you are very likely looking for this. In my case, I was on the need to perform hot-code Android updates pushed from my server without forcing the users to update the app from the PlayStore.

How it works

This library relies on the Android's build stack, and given a Library module:

  • Forces the assemble of the AAR package
  • Extracts the classes.jar and perform dexing on it using the dx tool.
  • Repackages the generated classes.dex along with all original Java resources from classes.jar into an mymodule.lib.apk file

Note: This tool will allow you to push updates of Java (Android) code and Java resources. Android's resources (strings, drawables, etc) or any other Android specific component are not supported.

Usage

On your build.gradle add:

plugins {
    id 'com.github.gmazzo.apklib' version '0.3'
}

apply plugin: 'com.android.library'

After applying the plugin, a task bundleLibApk per variant will be added to your build. On a default configuration will be bundleLibApkDebug and bundleLibApkRelease.

What's next?

Check the provided example-app and example-lib for a full working example of this library with hot-code loading. You may easily replace the content from the asset with the response from a web endpoint.

This repository also serves as an example of:

  • Building and publishing a Gradle's plugin (also linked to another plugin like Android's one in this case)
  • Full Kotlin + Dagger 2 working code
  • Kotlin Android Layout Extensions working code (to avoid findViewById())
  • Dagger's Android module working code
  • Android's buildConfigField usage
  • Gradle and Android sourceSet specific dependencies working code
  • Gradle's tasks input and output definition for proper UP-TO-DATE support on custom tasks
  • Gradle's tasks dependency (including cross-project linking) with dependsOn and evaluationDependsOn
  • Android's assets generation with Gradle's tasks
  • Gradle's includeBuild and dependencySubstitution working code, for in-build live plugin build and testing
  • Advanced ProGuard obfuscation like -keep,allowobfuscation, -flattenpackagehierarchy and -adaptresourcefilecontents
  • Exploration of Java backend concepts of ClassLoader and ServiceLoader

gradle-apklib-plugin's People

Contributors

gmazzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.