2017-10-21 77 views
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' 
} 

有人可以幫我嗎?林不知道要使用什麼和我混淆使用哪個版本。有人可以解釋更多細節嗎? 這是我編寫gradle時的編碼。我應該爲我的compileSdkVersion設置什麼?

回答

0

使用與編譯工具版本的前綴相同的編譯SDK版本。並始終爲最新的一個去。所以現在使用26。

1

compileSdkVersion

compileSdkVersion屬性指定編譯目標。

最新目標SDK版本是26所以用編譯SDK版本26.

compileSdkVersion是應用程序是對編譯API的版本。這意味着您可以使用該版本API中包含的Android API功能(以及所有以前的版本,顯然)。如果您嘗試使用API​​ 16功能,但將compileSdkVersion設置爲15,則會收到編譯錯誤。如果設置compileSdkVersion 16則仍可以將API 15設備上運行的應用程序,只要你的應用程序的執行路徑不嘗試調用任何API特定於API 16

查看更多here

0

你應該總是使用相同的版本在您的build.gradle如下:

  1. compileSdkVersion
  2. buildToolsVersion
  3. targetSdkVersion
  4. 支持庫

因爲你設置的support librarybuildToolsVersion到版本26,那麼你需要用堅持上述所有列表。這是使用buildToolsVersion "26.0.1"時,因爲你指定的API 26.因此,構建工具,你需要你的build.gradle改變這樣的事情(閱讀評論):在更Configure Your Build

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' 
} 

閱讀

相關問題