简体   繁体   English

Android Studio Build.Gradle同步错误

[英]Android Studio Build.Gradle Sync Error

I am experiencing a problem building my application in Android Studio. 我在Android Studio中构建应用程序时遇到问题。 I am using Android Studio 2.2 Preview 7. When I start up my Android Studio it gives an error: 我正在使用Android Studio 2.2 Preview 7.当我启动Android Studio时,它会出错:

The plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to xxxxxxx. 该插件太旧,请更新到更新的版本,或将ANDROID_DAILY_OVERRIDE环境变量设置为xxxxxxx。

It requests I fix plugin version and sync project. 它要求我修复插件版本和同步项目。 I have made all the required updates but the error remains. 我已经完成了所有必需的更新,但错误仍然存​​在。 I have read similar questions on the issue but they don't seem to apply to my case. 我在这个问题上已经阅读了类似的问题,但它们似乎并不适用于我的案例。

Could you please assist in providing me with a working solution? 你能协助我提供一个有效的解决方案吗?

Here is my build.gradle file: 这是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.3"
  defaultConfig {
    applicationId "com.mobileappdev.novarttech.sunshine"
    minSdkVersion 10
    targetSdkVersion 23
    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(dir: 'libs', include: ['*.jar'])
  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
  })

  compile 'com.android.support:appcompat-v7:23.3.0'
  compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
  compile 'com.android.support:design:23.3.0'
  testCompile 'junit:junit:4.12'
}

As per my observation it seems like you haven't updated Android SDK platform to version 25. First of all download and install android sdk platform and build tools from SDK Manager and use the following lines in your build.gradle(module app) 根据我的观察,似乎你没有将Android SDK平台更新到25版。首先从SDK Manager下载并安装android sdk平台和构建工具,并在build.gradle中使用以下行(模块应用程序)

compileSdkVersion 25
buildToolsVersion "25.0.0"

Also update dependencies according to that. 还要根据它更新依赖关系。 It should work then 它应该工作

As @claudio-redi says, you need to upgrade your build gradle tools. 正如@ claudio-redi所说,你需要升级你的构建gradle工具。

Use build tools 2.2.2 to your root build.gradle : 使用构建工具2.2.2root build.gradle

classpath 'com.android.tools.build:gradle:2.2.2'

And change the gradle distribution to 2.14.1 in gradle/wrapper/gradle-wrapper.properties file with: 并在gradle/wrapper/gradle-wrapper.properties文件中将gradle分布更改为2.14.1

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

Or if you already have download the gradle distribution and place it in a directory, you can set it in your Android Studio from menu File->Setting->Gradle and set it as the following image: 或者,如果您已经下载了gradle发行版并将其放在目录中,则可以从菜单File->Setting->Gradle在Android Studio中进行File->Setting->Gradle ,并将其设置为以下图像:

在此输入图像描述

Please be noted when you want to use API Level 25 you need to make sure that compileSdkVersion , buildToolsVersion , targetSdkVersion , and Support Library using the same API Level 25. 请注意,当您要使用API级别25时,您需要确保使用相同的API级别25的compileSdkVersionbuildToolsVersiontargetSdkVersionSupport Library

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM