Android Version plugin


Source link: https://github.com/kaminomobile/AndroidVersion

Android Version plugin

Android Version plugin is a gradle plugin that helps managing version for Android projects. Plugin is especially helpful when you are dealing with complex build structure with multiple flavors and apk splits.

Features

  • Version name and code manipulation
  • Per flavor & build type version manipulation
  • Per split version manipulation
  • Multi dimensional flavor version manipulation
  • Rule based automatic version code calculation
  • Rename apk file name

Usage

Apply plugin

buildscript {

  repositories {

maven {

 url "https://plugins.gradle.org/m2/"

}

  
}

dependencies {

 classpath "gradle.plugin.si.kamino.gradle:android-version:1.3.2"
  
}
 
}
  apply plugin: "si.kamino.version"

Configuration

androidVersion {

fileNamePattern 'sample-$flavors.dimension-$versionName'

appVersion {

major 1

versionCode {

 digits 2

}

  
}

variants {

variant1 {

 minor 2

}

 variant2 {

 minor 5

}

debug {

 build 1

}

variant1Debug {

 build 3

}

}

 splts {

abi {

 x86 {

  versionCode(IncreaseVersionCode) {

by 1000000

  
}

 
}

}

  
}
  
}

Flavor combinations

Beside configuring version based on flavors and build types you can also do that on combinations of them when using multiple variant dimensions. Combinations are calculated based on dimension order. For example if you have flavor1 and flavor2 that are in different dimensions you could do configuration for flavor1Flavor2 and also flavor1Flavor2Debug. If you define both second one will override first one if they have sem properties set.

Version code types

Based on your need you can specify version code tactics that you want to use. By default appVersion uses SimpleVersionCode tactics but this can easily be changed. Version code tactics can also be changed per variant/split. It can ether modify existing version code or specify completely new value.

  • SimpleVersionCode creates version code from version name parameters ( major, minor and build). By default each part will take up 2 digits but this is configurable through digits parameter.
  • IncreaseVersionCode Similar than SimpleVersionCode but you can specify digits per each part.
  • StaticVersionCode sets static value defined in versionCode parameter.
  • IncreaseVersionCode increases previously calculated value by value defined in by parameter.

By default plugin will set SimpleVersionCode with digits set to 2.

Output file name

With fileNamePattern property you can easily rename out apk files. Alongside static values you can specify template and plugin will generate the file name. Available properties are:

  • project: name of the project. In case of default Android Studio template that would be app.
  • variantName: full unique name of the variant including filters.
  • buildType: build type of the variant
  • flavorName: name of all flavors combined with capitalized latter
  • versionCode: version code of output file including apk splits
  • versionName: version name of output file including apk splits
  • flavors by dimension map of all flavors. (for example: flavors.dimension)

.apk suffix is automatically added at the end of file name.

Limitations

Due to the changes in Android Gradle plugin 3.0.0, Android version plugin 1.2.3 or above is required. Android version plugin is fully backwards compatible and new version will work with old version of Android gradle plugin.

There are some instant run limitations in versions before 2.3.0 of Android Gradle plugin due to bug. Due to this issue plugin will be disabled if it detects that it is running under instant run. That means that version name will be empty and version code will be 0. That is ok for tho most cases, if not you can still set version the old way in android.defaultConfig. When using Android Gradle Plugin 2.3.0 or newer everything works as espected.

License

MIT License  Copyright (c) 2017 Kamino d.o.o.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

Resources

Linear layout, that wrap its content to the next line if there is no space in the current line.

OpenALPR is an open source Automatic License Plate Recognition library.

A LayoutManager that must be used with RecyclerView. When list is scrolled views are moved by circular trajectory.

RealParallaxAndroid is a View Pager with a Real Parallax Android Effect.

An image-view with circle loading animation.

Sectioned RecyclerView allows you to easily split a RecyclerView into sections with headers.

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