Freeline


Source link: https://github.com/alibaba/freeline

Freeline

Freeline is a super fast build tool for Android and an alternative to Instant Run. Caching reusable class files and resource indices, it enables incremental building Android apps, and optionally deploying the updates to your device by hot swap.

See Freeline official website for more information.

Developed and used by Ant Fortune ( about us) Android Team, Freeline has been significantly saving time in daily work. Inspiring by Buck and Instant Run but faster than ever, Freeline can make an incremental build in just a few seconds. No more recompile and reinstall again and again before seeing your modifications, Freeline brings life-changing development experience for Android.

????

Freeline Insights

Freeline splits the build task into several small tasks that run concurrently. It makes full use of the compiled cache files to implement a real incremental build and uses some components of Buck such as dx and DexMerger to speed up the build tasks. Freeline runs a socket server in a separate process on device side, which connects with build tool on developer's machine, so that deployment can still take effects even if the main process crashes.

Freeline uses multi-dex solution for incremental dex hot swapping. A deeply optimized version of aapt tool ( FreelineAapt) is made to generate incremental resource pack, which is several times faster than the original aapt tool and the resouce pack can be as small as 1kb. MonkeyPatcher from Instant Run is utilized to make hot resource replacement. Freeline support dynamic swap native .so library, you don't need to re-build your project after native .so files changed.

Freeline will automatically switch between full build and incremental build.

Freeline is also a great basis for over-the-air hotpatching. Deliverying Freeline's incremental output, which can be packed into a zip file and usually less than 100 kb, it is able to take effect to fix crashes or other problems and replace resoucres dynamically. Statistical data over large amount cases show that it is effective for 99% of users. Please note that the OTA patch delivery system is out of scope of this project.

FreelineAapt will open source codes later. See wiki to know more about Freeline, only Chinese available now.

??????

Features

  • Speed up standard android gradle projects with multiple modules
  • Concurrent tasks that incrementally build project
  • Hot deploy even if the main process crashes
  • Build incremental dex and resource pack
  • Caching resource.arsc support
  • Running on Windows, Linux and Mac
  • Native so hot swap support
  • Annotation support
  • Retrolambda support
  • DataBinding support

See the following table for changes support.

Java drawable, layout, etc. res/values native so
add
change
remove x -

Freeline has been tested with API versions 17, 19, 22, 23 on the android emulators, a Nexus 6p running marshmallow and a smartisan running Kitkat. Incremental resource patch would be much faster if the android device is running Lolipop or above.

Download

Configure your project-level build.gradle to include freeline plugin:

buildscript {

  repositories {

jcenter()
  
}

  dependencies {

classpath 'com.antfortune.freeline:gradle:0.8.8'
  
}
 
}

Then, apply the freeline plugin in your android application module's build.gradle:

apply plugin: 'com.antfortune.freeline'  android {

  ... 
}

Finally, execute the gradle task initFreeline to download freeline dependencies.

  • Windows[CMD]: gradlew initFreeline
  • Linux/Mac: ./gradlew initFreeline

For Chinese users, if you got stuck in the download process, you can execute gradlew initFreeline -Pmirror to speed up the progress.

You can also use -PfreelineVersion={ your-specific-version } parameter to download the specific version of freeline's python and bin dependencies.

If you have a complex project structure, you may need to use freeline DSL to customize your build process. For more details about freeline DSL, see Freeline DSL References.

Usage

You can install freeline plugin in Android Studio for quick usage.

How to install? In Android Studio, go to:

  • MacOS

Android Studio → Preferences... → Plugins → Browse repositories...

  • Windows and Linux

File → Settings... → Plugins → Browse repositories...

and search for freeline.

Just use the Run Freeline button and enjoy it.

The plugin will show you the latest update of Freeline, you can use this plugin to update Freeline.

Many thanks to @pengwei1024 and @act262 for creating such an awesome plugin.

Besides, you can also execute python script in the command line in the root dir of your project. See wiki for more details.

Sample Usage

git clone [email protected]:alibaba/freeline.git cd freeline/sample ./gradlew initFreeline python freeline.py 

TODO

  • Compatibility Improvement
  • Multiple Devices Connection Support

Limitations

  • Sync incremental resource pack to the device first time may be a bit slow
  • Removing res/values is not supported, which may cause aapt exception
  • Incrementally build abstract class is not support
  • Not support Jack compile
  • Not support Kotlin/Groovy/Scala

Contributing

We are always very happy to have contributions, whether for trivial cleanups, big new features or other material rewards.

Troubleshooting

See wiki.

Thanks

License

BSD3 License

Resources

This example project illustrates how to implement an animated radial button layout in Android.

Lollipop ViewAnimationUtils.createCircularReveal for everyone 2.3+

Android specific bindings for RxJava.

This module adds a number of classes to RxJava that make writing reactive components in Android applications easy and hassle free.

String operators for RxJava.

advanced-textview is a companion app for Advanced Android TextView talk, demonstrating:

  • Animated CompoundDrawable
  • Text shadow
  • Custom font
  • Gradient text
  • Patterned text
  • HTML.fromHtml()
  • setFontFeatureSettings()
  • Styled string
  • AlignmentSpan
  • ClickableSpan
  • Rainbow span, animated
  • Lined paper
  • Emoji

Views and Drawable for animated GIFs in Android.

Bundled GIFLib via JNI is used to render frames. This way should be more efficient than WebView or Movie classes.
Animation starts automatically and run only if View with attached GifDrawable is visible.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes