How to check the latest version of android support library in your SDK?

In order to the Android Support Library, we need to add the support library to dependencies in build.gradle. For example, add the following lines.

dependencies {
compile ‘com.android.support:design:25.1.0'
compile ‘com.android.support:appcompat-v7:25.1.0’
}

When do you update the support library version?

In my case, when IDE recommends to update SDK at the right top corner or when I open the SDK manager which provides the SDK tools, platforms, and others, I download and update the selected packages.

After downloaded, targetSdkVersion of defaultConfig shows the warning message with yellow underline “Not targeting the latest versions of android compatibility modes apply. consider testing this version.” for being compatible with the latest Android changes, so let’s set targetSdkVersion to 25 (Android 7.1) and run gradle build.

Finally, we will see the notice which means the support library version must be replaced to the latest version you have in your SDK and the targetSdkVersion must be the same.

How to check the latest version of android support library in your SDK?

Andorid Support Repository is local maven repository which contains all the support libraries as AAR archives from Android.

m2repository installed from dl.google.com.

As the result, you will find the latest version of support library in your local SDK. Update 25.0.1 version for com.android.support:appcompat-v7, sync project with Gradle files and run project.

failed to find target with hash string ‘android-XX’ in Jenkins CI

compileSdkVersion, minSdkVersion, and targetSdkVersion

First of all, read this ‘Picking your compileSdkVersion, minSdkVersion, and targetSdkVersion’ to know what these mean for building your project.

compileSdkVersion, minSdkVersion, and targetSdkVersion come in: they control what APIs are available, what the required API level is, and what compatiblity modes are applied, respectively. – Ian Lake’s blog

I’ve updated android latest compileSdkVersion, targetSdkVersion and buildToolsVersion on my Android project a couple of days ago, installing the latest version of the Android platform as android-24 and buildTools as 24.0.1.

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.1'

    defaultConfig {
        targetSdkVersion 24
….

What went wrong :

But Jenkins gives this error through slack-plugin as below.

Jenkins Bot Message on Slack

Check Console Output on Jenkins

It failed to find android sdk 24 in android-sdk-linux directory because compileSdkVersion sets 23 to the newest API 24. So you can check list installed SDK package so far via command line.

$ cd /opt/android-sdk-linux/platforms
$ ls
android-10  android-15  android-16  android-17  android-18  android-19  android-20  android-21  android-22  android-23  android-8

You will understand it’s no android-24 folder, to compile app by API level 24 so let’s add android-24 to platforms and also Android SDK Build-tools, version 24.0.1. See the package list for Android SDK Tools, Android SDK Platform-Tools, Android SDK Build-tools, Google Play services, Google Admob and etc.

How To Update SDK

$ cd /opt/android-sdk-linux/tools
$ ./android list sdk --all
Packages available for installation or update: 156
   1- Android SDK Tools, revision 25.1.7
   2- Android SDK Tools, revision 25.2.1 rc1
   3- Android SDK Platform-tools, revision 24.0.1
   4- Android SDK Build-tools, revision 24.0.1
   5- Android SDK Build-tools, revision 24
   6- Android SDK Build-tools, revision 23.0.3
   7- Android SDK Build-tools, revision 23.0.2
   8- Android SDK Build-tools, revision 23.0.1

………

  29- SDK Platform Android 7.0, API 24, revision 2
  30- SDK Platform Android 6.0, API 23, revision 3
  31- SDK Platform Android 5.1.1, API 22, revision 2
  32- SDK Platform Android 5.0.1, API 21, revision 2
  33- SDK Platform Android 4.4W.2, API 20, revision 2
  34- SDK Platform Android 4.4.2, API 19, revision 4
  35- SDK Platform Android 4.3.1, API 18, revision 3

……….

 108- Google APIs, Android API 23, revision 1
 109- Google APIs, Android API 22, revision 1
 110- Google APIs, Android API 21, revision 1

Now we need to install No.29, ‘SDK Platform Android 7.0, API 24, revision 2’, to build in Jenkins successfully. So try to install by commend line as below.

$ sudo ./android update sdk -a -u -t 29

Try build it again in Jenkins. Finally, the problem was fixed and build was finished successfully.