簡體   English   中英

Android Studio Build.Gradle同步錯誤

[英]Android Studio Build.Gradle Sync Error

我在Android Studio中構建應用程序時遇到問題。 我正在使用Android Studio 2.2 Preview 7.當我啟動Android Studio時,它會出錯:

該插件太舊,請更新到更新的版本,或將ANDROID_DAILY_OVERRIDE環境變量設置為xxxxxxx。

它要求我修復插件版本和同步項目。 我已經完成了所有必需的更新,但錯誤仍然存​​在。 我在這個問題上已經閱讀了類似的問題,但它們似乎並不適用於我的案例。

你能協助我提供一個有效的解決方案嗎?

這是我的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'
}

根據我的觀察,似乎你沒有將Android SDK平台更新到25版。首先從SDK Manager下載並安裝android sdk平台和構建工具,並在build.gradle中使用以下行(模塊應用程序)

compileSdkVersion 25
buildToolsVersion "25.0.0"

還要根據它更新依賴關系。 它應該工作

正如@ claudio-redi所說,你需要升級你的構建gradle工具。

使用構建工具2.2.2root build.gradle

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

並在gradle/wrapper/gradle-wrapper.properties文件中將gradle分布更改為2.14.1

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

或者,如果您已經下載了gradle發行版並將其放在目錄中,則可以從菜單File->Setting->Gradle在Android Studio中進行File->Setting->Gradle ,並將其設置為以下圖像:

在此輸入圖像描述

請注意,當您要使用API級別25時,您需要確保使用相同的API級別25的compileSdkVersionbuildToolsVersiontargetSdkVersionSupport Library

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM