Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting gradle to Android O (API 26)

Tags:

Android studio has automatically update the following components to API 26:

  • ROM - SDK to API 26
  • Android SDK Build-Tools 26
  • Android Emulator 26.0.3
  • Android SDK Platforms-Tools 26.0.0
  • Android SDK Tools 26.0.2

My gradle 2.3.3:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.0'
    defaultConfig {
        applicationId "com.mycompany.myapplication"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 4
        versionName "0.0.4"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    /////////If I change it to 26.0.0 it gives errors.///////////
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-vector-drawable:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    /////////////////////////////////////////////////////////////
    testCompile 'junit:junit:4.12'
}

I have two questions (see commented line in Gradle):

How can I know the latest version of these libraries (I simply throw random numbers and try to up them until I found the latest version).

In the excluded group there is 'com.android.support', if I delete that do I need to specify those libraries? I see many people including 'com.android.support' libraries this way so there is a reason I guess to do so.

I searched in developer.android.com and the latest version is 24.2.0 (so really old I have been using 25.3.1).

like image 745
Exprove Avatar asked Jun 26 '17 09:06

Exprove


1 Answers

If you really want to use the 26 version you could use the + character at the end of your dependencies.

compile 'com.android.support:appcompat-v7:26+'

This way, grade will take the latest version beginning with 26.?.? of your dependency. But you will get a warning from Android Studio, because between two different versions the behavior could eventually change and then produce random effect.

To know the latest version, just take a look here : https://developer.android.com/topic/libraries/support-library/revisions.html

And to finish, if you include 'com.android.support', you will include the whole library. And you certainly not need all the stuff included. If you only use recycler view just add :

compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
like image 55
olivejp Avatar answered Sep 22 '22 17:09

olivejp