Android studio 无法生成工具版本android

Android studio 无法生成工具版本android,android-studio,gradle,android-gradle-plugin,build.gradle,Android Studio,Gradle,Android Gradle Plugin,Build.gradle,我试图在新安装的android studio中打开我的一个旧项目(今天),它给了我以下错误: failed to find build tools revision 23.0.0 rc2 install build tools 23.0.0 rc2 and sync project 我在互联网上查找它,并尝试将其添加到gradle文件中: android { compileSdkVersion 22 buildToolsVersion "22.0.0" } // Top-level buil

我试图在新安装的android studio中打开我的一个旧项目(今天),它给了我以下错误:

failed to find build tools revision 23.0.0 rc2
install build tools 23.0.0 rc2 and sync project
我在互联网上查找它,并尝试将其添加到gradle文件中:

android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
  }
}

allprojects {
repositories {
    jcenter()
  }
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
}
它给了我另一个错误:

gradle DSL method not found: 'android()'
possible causes:
the project may be using a version of gradle that does not contain the method.
gradle settings.
the build file may be missing a gradle plugin.
apply gradle plugin.
这是我的gradle文件:

android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
  }
}

allprojects {
repositories {
    jcenter()
  }
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
}

在顶级
build.gradle
中,您必须删除
android

android {
   compileSdkVersion 22
   buildToolsVersion "22.0.0"
}
只需使用:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

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

    allprojects {
       repositories {
         jcenter()
       }
    }
您必须使用
app/build.gradle
中的
android
块,在该块中您应该定义如下内容:

apply plugin: 'com.android.application'

android {
    compileSdkVersion XX
    buildToolsVersion "XX.X.X"

    defaultConfig {
       minSdkVersion XX
       targetSdkVersion XX
       versionCode 1
       versionName "1.0"
    } 
    buildTypes {
      release {
         //......
      }
    }
}
dependencies {
  //......
}

我检查了安装在Android Studio中的构建工具版本,我有Android SDK构建工具rc3,而不是rc2。 我在build.gradle(模块应用程序)中将其更改为 安卓{ 编译DK22版 buildToolsVersion“23.0.0 rc3”} 在那之后它就开始工作了。 检查是否存在相同的问题。

有两个渐变文件

您必须修改的是此目录下的目录 应用程序名称/APP/BUILD.GRADLE

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "PUT THE CODE YOU WANT HERE EX "23.0.0 r3""

    defaultConfig {
        applicationId "org.app.appname"
        minSdkVersion 10
        targetSdkVersion 22
        versionCode 9
        versionName "1.10.3"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:7.5.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile files('libs/volley.jar')
}
不是看起来像这些的那个

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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()
    }
}

右键单击项目>打开模块设置>属性选项卡,然后更改:

Compile Sdk Verion to API 23: Android 6.0
Build Tools Version 23.0.0

在我的情况下,我尝试了一切,最后我不得不做一个简单的改变

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc2"
}
对此

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0" //DELETE rc2 AND SYNC PROJECT 
}

这取决于您安装的Android SDK构建工具的版本,您可以通过SDK管理器进行检查,在我的情况下,我没有安装23.0.0 rc2,而是23.0.1,因此您需要编辑您的
应用程序/Build.gradle

对我来说,那是:

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.1"
}

实际上,我把它误认为是另一个gradle文件,而不是更改项目的build.gradle,而是在libraries build.gradle中编写