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

阅读

相关问题