2015-08-22 91 views
46

我創建了一個簡單的項目,然後右鍵單擊該項目,然後使用make mudole app選項。現在我有兩個build.gradle文件夾:1- build.gradle:project My Application。 2- build.gradle: Mudole app。第一build.gradle如下:錯誤:錯誤原因:未指定buildToolsVersion

// Top-level build file where you can add configuration options common to all sub-projects/modules. 
apply plugin: 'com.android.library' 
buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.3.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

而第二Build.gradle文件夾如下:

apply plugin: 'com.android.application' 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 

    defaultConfig { 
     applicationId "com.exam.exam.myapplication" 
     minSdkVersion 7 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
} 

現在我點擊run選項來創建這個項目aar文件,但我得到以下錯誤:

Error:Cause: buildToolsVersion is not specified. 
+0

你有沒有這方面的任何解決方案? –

+0

這個問題可以通過在模塊 –

+0

的設置中指定構建gradle網站來解決我有同樣的問題。我做錯了,當我添加一個新的模塊到我的項目中,沒有在模塊的gradle文件中指定buildToolsVersion。所以我添加了相同的內置版本的應用程序TO模塊。 –

回答

-6

嘗試無效緩存/重新啓動,它解決了這個這樣的更新後文件 - >無效緩存/重啓

+0

我做了這個動作但我仍然有同樣的錯誤。 – developer

68

我有同樣的問題。我所做的錯在於將應用插件語句放在項目的根節點上。當我將它放入應用程序gradle中時,問題就解決了。

我的建議是檢查你是否在根gradle中放置了一些你應該放在app gradle中的語句。

+2

是的,在我的情況下,它是根項目中build.gradle類路徑依賴項的重複 – rus1f1kat0R

7
文件

...的build.gradle(項目:XXX):

repositories{ 
    //put pluging repository here 
    //e.g.: 
    mavenCentral() 
} 
dependencies{ 
    //classpath to plugin here 
    classpath 'com.XXXX.xXXxxXX.XXXX' 
} 
文件

....的build.gradle(模塊:APP)

//add on top: 
apply plugin: 'com.YOUR.PLUGIN.XXX' 
1

不能確定什麼潛在的問題是,但我發現在發生併發問題的解決方案: https://stackoverflow.com/a/32490472/1544046

本質上,我不得不改變我的gradle目標使用包裝,而不是德罰款的路徑。過去我已經將它設置爲Gradle Wrapper,但它似乎不時地通知我。一旦我切換回來並重新編譯,它工作得很好。

在項目設置中:構建,執行,部署 - >構建工具 - > Gradle並選擇「使用默認的gradle wrapper」。

0

的Android項目> setting.gradle

include ':app' , ':xxx' 

我輸入模塊的一個和這個致毒此錯誤。我刪除它是固定的。

include ':app' 
+0

但是不是「include」:app',':xxx'「如何將指定模塊與名稱」xxx「集成?所以基本上你不是真的包含模塊?如果我錯了,請糾正我。 – leiseliesel

+0

我只是舉例:)它不是:xxx .. 我手動添加了一個模塊,並提到了自己添加的行.. – Huseyin

3

我的問題是,andorid-versionCode只能是整數值。 build.xml中:

如:Android系統的versionCode = 「1」

它不能是 「1.1」 等等 錯誤代碼是沒有幫助的。

+0

爲什麼我無法讓你兩次? –

0

檢查build.gradle中的android studio版本是否與正在運行的版本相同。

buildscript { 

    repositories { 
     google() 
     jcenter() 
    } 
dependencies { 
    classpath 'com.android.tools.build:gradle:3.0.0' 


    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
    } 
} 

就我而言,我打開/進口在Android Studio中3的Android 2.3.3工作室創建的項目,我能夠與3.0.0

更新的build.gradle後襬脫這一問題的
3

我已經通過在項目中添加以下行來解決問題,請檢查它可能會幫助您擺脫困境。

add this line to app gradle

buildToolsVersion "27.0.1"

搖籃

android{ 
      compileSdkVersion 27 
      buildToolsVersion "27.0.1" 
      useLibrary 'org.apache.http.legacy' 
     } 
相關問題