android-appversion-gradle-plugin


Source link: https://github.com/hamsterksu/android-appversion-gradle-plugin

android-appversion-gradle-plugin

  1. Easy way to add build number to your application version
  2. Easy way to change APK name and add extra data to it.

Supported version of gradle-android-plugin

  • 0.12.+ -> - com.github.hamsterksu:android-appversion-gradle-plugin:1.0.+
  • > 0.14.+ -> - com.github.hamsterksu:android-appversion-gradle-plugin:1.2.+
  • 1.0.+ -> - com.github.hamsterksu:android-appversion-gradle-plugin:1.2.+

?ontents

  1. How to use
  2. Add plugin to dependencies
  3. Apply plugin
  4. Configure plugin
  5. Available options
  6. Typical usecases
  7. Use brackets in some cases
  8. What is versions.properties file?
  9. Configuration examples

Typical usecases

Do you want to use package name, app version name and version code in file name?

Just use the following fileNameFormat: $appPkg.$versionName($versionCode)

Result - com.yourdomain.app.1.0.0.1(1).apk

Use brackets in some cases

Why do you need to use brackets { } in some cases?

fileNameFormat - is a Groovy string. Be careful to use something like $appPkg.v_$versionName. Groovy will try to find the "v_" property in the String object. And you will get Error: > No such property: v_ for class: java.lang.String.

In this case you need to use { } : ${ appPkg } .v_$versionName

How to use

Add plugin to dependencies

buildscript {

  repositories {

mavenCentral()  
}

dependencies{

classpath 'com.github.hamsterksu:android-appversion-gradle-plugin:1.+'  
}
 
}

Apply plugin

apply plugin: 'versionPlugin'

Configure plugin

versionPlugin{
  buildTypesMatcher = 'release'
supportBuildNumber = true  buildNumberPrefix = 'b'
 fileNameFormat = '$appPkg-v_$versionName-c_$versionCode' 
}

Available options:##

  • buildTypesMatcher - regexp value. the most useful case: if you want to apply changes for one build type use buildTypesMatcher = 'release' if for both buildTypesMatcher = 'release|debug'. Sure you can use any regexp value.
  • supportBuildNumber - use true if you want to add build number to appVersion. versions.properties file will be generated in root project. you can add it to version control ignore list if you use CI or you are alone devloper in the team.
  • buildNumberPrefix - string value, prefix before build number. example: 1.0.0.b1
  • fileNameFormat - groovy template string. you can specify your own format of APK file name. Available variables in the formatted string:
    • appName - name of main module
    • projectName - name of root project
    • flavorName - falvour name
    • buildType - build type
    • versionName - version name
    • versionCode - version code
    • appPkg - application id
    • date - build date, you can specify your own date format use dateFormat propery
    • time - build time, you can specify your own date format use timeFormat propery
    • customName - use this template to use string from customNameMapping
  • dateFormat - format string for SimpleDateFormat
  • timeFormat - format string for SimpleDateFormat
  • customNameMapping - mapping for $customName. it's groovy map for variantName -> text

Example:

customNameMapping = [
  'debug':'MySuperApp',
  'releae':'MySuperApp' ]
customNameMapping = [
  'flavourDebug':'MySuperApp',
  'flavourRelease':'MySuperApp' ]

What is versions.properties file?

If you turn on supportBuildNumber plugin will generate versions.properties file in root project. it store current build number for each flavour. You can add it to version control ignore list if you use CI or you are alone devloper in the team.

Config examples

versionPlugin{

  buildTypesMatcher = 'release|debug'

supportBuildNumber = true
  buildNumberPrefix = 'b'

fileNameFormat = '$customName-$versionName($versionCode)-$buildType'

customNameMapping = [

'debug':'mysuperapp',

'release':'mysuperapp'
  ] 
}
versionPlugin{

  buildTypesMatcher = 'release'
  supportBuildNumber = true

 fileNameFormat = '$appPkg-$versionName($versionCode)' 
}
versionPlugin{

  buildTypesMatcher = 'release'
  supportBuildNumber = false

 fileNameFormat = '$projectName-$flavorName-$versionName($versionCode)-$date-$time'
  dateFormat = 'dd-MM-yyyy'
  timeFormat = 'HH:mm' 
}

Resources

SwagPoints - An Android custom circular SeekBar that supports max/min range and step settings.

Android Loaders for the rest of us.

The concept of loaders in Android is pretty great: a way to do async work in a lifecycle-aware way. Unfortunately, the implementation is pretty bad. Loadie attempts to fix this in several ways.

Providing swipe feature for android applications.

You can now select a date and a time with only one widget!

A sample Android application to demonstrate how to build screens as fully independent modules.

It relies on a Finite State Machine (EasyFlow), to handle screens as states and trigger/consume events. Events allow the application to handle navigation between screens. The global context of the FSM is used to pass arguments as a Bundle. It also shows how to use dependency injection (via Dagger 2 for example) in modules.

This way:

  • modules are fully independent
  • modules declare the dependencies they need
  • modules declare the states they correspond to
  • modules declare the events that can be triggered
  • the hosting application sets up the states it uses (i.e., "screens")
  • the hosting application sets up how to navigation between states (with events)
  • the hosting application sets up the dependency injection mechanism

One of the fastest caching libraries for Java. Lots of features for advanced integrations of external systems: (Variable entry) expiry, exception handling with configurable resilience, loaders/writers, events, statistics. Configuration can also be done via XML (optional feature).

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