How to publish artifacts (Android Library in "aar" format) to Maven repo from Android Studio gradle

This post shows build.gradle configuration to be able to push artifacts to local Maven repo. I've taken Android library in its "aar" format as artifact for example.

First add "maven-publish" plugin to enable publishing artifacts from build.gradle:
apply plugin: 'maven-publish'
Don't forget to add local maven repo:
repositories {
    mavenLocal()
}
Add publishing block now:
publishing {
    publications {
        mavenJava(MavenPublication) {
            groupId <GROUP_ID>
            artifactId <ARTIFACT_ID>
            version <currentVersion>

            artifacts = ["${buildDir}/outputs/aar/<your_android_library>.aar"]
        }
    }
}

How to create annotated Git tags

Annotated Git tags keep the information of related with tag and permanent in nature. It can be created using this command:
git tag -a <tagname>
An already existing tag can be modified using flag "-f" like this:
git tag -a -f <existing_tag_name>
A specific tag can be pushed to remote like this:
git push origin <tagname> 
Deleting tags:

  • Deleting remote tag:
git push origin :<tagname> OR git push --delete origin <tagname>
  • Deleting local tag
git tag -d <tagname>

General guidelines: 
  •  git push where-to-push source-refs:destination-refs
  • git push <remote> <local-branch>:<remote-branch>
  • git push origin refs/head/master:refs/heads/master
  • git push origin master:master



How to change author for a GIT commit


  • First fix up the author details in .git/config file for the given repo by adding this block
[user]
                  name = <new name>
                  email = <new email>
   
  • Now execute following command to amend the commit:
git commit --amend --reset-author

Creating remote GIT branch

You can create a new local branch like this:
git checkout -b <branch_name>

If you want to make it a remote branch, then it can be pushed to remote like this (make sure that you're in this new branch):
git push origin <branch_name>

But sometimes, this newly pushed branch to remote doesn't get updated on remote location. Remote branches could be forced refreshed like this:
git remote update origin --prune 
If you want to delete a local branch:
git branch -d <branch_name>
If you want to delete this branch in remote too, then:
git push origin :<branch_name> 
 

Updating Android SDK tools from commandline

  • View all available downloads for build tools:
android list sdk --all 
  •  Updating packages
 android update sdk --no-ui --all --filter <package_number1, packager_number2, ...>
  •  Updating packages (without alias)
android update sdk -u -a -t <package_number1, packager_number2, ...>

To see the list of AVDs created/available :
android list targets 

SigningConfig for Gradle - Android

Add following code snippet in your build.gradle:

signingConfigs {
   debug {
      storeFile file('<full-path-to-keystore>/.android/debug.keystore')
      storePassword 'android'      keyAlias 'androiddebugkey'      keyPassword 'android'   } 
}
Add More variants for each flavor like release.

Scheduling Repeating Local Notifications using Alarm Manager

Learn about Scheduling Repeating Local Notifications using Alarm Manager in this post .