1
apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.ta2323.ftsm.lab_recyclerview_a160158"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        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'
    })
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    compile 'com.android.support:cardview-v7:26.0.0-alpha1'
}

Can someone help me? Im not sure what to use and im confuse to use which version. Can someone explain more detail? This is my coding in build gradle.

Tatul
  • 11
  • 3

3 Answers3

1

compileSdkVersion

The compileSdkVersion property specifies the compilation target.

The latest target sdk version is 26 so use compile sdk version 26.

The compileSdkVersion is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API (as well as all previous versions, obviously). If you try and use API 16 features but set compileSdkVersion to 15, you will get a compilation error. If you set compileSdkVersion to 16 you can still run the app on a API 15 device as long as your app's execution paths do not attempt to invoke any APIs specific to API 16.

See more here

Nongthonbam Tonthoi
  • 12,667
  • 7
  • 37
  • 64
0

Use the compile SDK version the same as the prefix of build tools version. And always go for the latest one. So use 26 for now.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
0

You should always use the same version for the following in your build.gradle:

  1. compileSdkVersion
  2. buildToolsVersion
  3. targetSdkVersion
  4. Support library

Because you set the support library and buildToolsVersion to version 26, then you need to stick with 26 for all the above list. This is because when using buildToolsVersion "26.0.1" you're specifying the build tools for API 26. So, you need to change your build.gradle to something like this (read the comment):

apply plugin: 'com.android.application'

android {

  /**
   * compileSdkVersion specifies the Android API level Gradle should use to
   * compile your app. This means your app can use the API features included in
   * this API level and lower.
   */

  compileSdkVersion 26

  /**
   * buildToolsVersion specifies the version of the SDK build tools, command-line
   * utilities, and compiler that Gradle should use to build your app. You need to
   * download the build tools using the SDK Manager.
   *
   * If you're using Android plugin 3.0.0 or higher, this property is optional—
   * the plugin uses the minimum required version of the build tools by default.
   */

  buildToolsVersion "26.0.2"

    defaultConfig {
        // Defines the minimum API level required to run the app.
        minSdkVersion 15

        // Specifies the API level used to test the app.
        targetSdkVersion 26

        ...
    }

}

dependencies {  
    ...
    // NEVER USE ALPHA Version in your dependencies.
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:recyclerview-v726.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
}

Read more at Configure Your Build

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96