2015-10-16 34 views
0

根據https://developer.android.com/tools/revisions/build-tools.html,該版本添加了對Android 6.0(包含新的requestPermission方法)的支持。build.gradle文件中的buildToolsVersion究竟有什麼作用?

Revision 23.0.0 (August 2015) 
    Added support 
    for the Android 6.0 (API level 23) release. 

我使用新requestPermission方法爲Android 6.0,但沒有更新buildToolsVersion - 但程序仍然有效,當我想到的構建過程失敗(見所附圖片)。

所以問題是:buildToolsVersion究竟做了什麼?我想知道22.0.1版爲什麼不應該這樣工作? android studio是否繞過了build.gradle文件中的值?的build.gradle

import groovy.swing.SwingBuilder 
apply plugin: 'com.android.application' 
apply plugin: 'me.tatarka.retrolambda' 
android { 
    compileSdkVersion 23 
    buildToolsVersion "22.0.1" 

    compileOptions { 
     encoding "UTF-8" 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 


    defaultConfig { 
     //Minimum FROYO 
     minSdkVersion 4 
     targetSdkVersion 23 


<snip off unrelated parts> 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:support-v4:23.0.1' 

    // ads: google play 
    googlePlayCompile 'com.android.support:appcompat-v7:23.0.1' 
    googlePlayCompile 'com.google.android.gms:play-services-ads:7.5.0' 

    testCompile 'org.robolectric:robolectric:2.4' 
    testCompile 'junit:junit:4.12' 
} 

編輯

enter image description here

相關章節中the other question回答說,我必須使用buildToolsVersion> = compileSdkVersion使用的新功能。然而,我正在使用這些新功能,而無需更新buildToolsVersion。

+1

http://stackoverflow.com/questions/24521017/android-gradle-buildtoolsversion-vs-compilesdkversion –

+0

@Amiya:這是在那裏我得到難倒...「您可以使用更高版本的編譯工具比你的compileSdkVersion,爲了選擇新的/更好的編譯器,而不改變你的應用程序構建你的應用程序。「我的buildTool版本低於compileSdkVersion(並且我正在使用compileSdkVersion中的新功能,這些功能不應該存在於較早的buildTool中) –

回答

0

它是編譯器的版本對於每個API級別。例如,如果我們使用compileSDKversion 20,我們可以使用buildToolsVersion 20.0.0或更高版本。