简体   繁体   中英

android : cannot build project after upgrading Android Studio to 2.3

So, happily updated my Android Studio from stable version 2.2 to canary channel 2.3.

But, unfortunately, it has serious bug. Project is not able to build. I tried opening my previous projects and also tried creating new sample application, I got same below error:

Gradle 'MyApplication' project refresh failed
Error:A problem occurred configuring project ':app'.

build.gradle(project):

// 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:2.3.0-alpha1'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.example.chint.myapplication"
        minSdkVersion 16
        targetSdkVersion 25
        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:25.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'com.android.support:design:25.0.0'
    testCompile 'junit:junit:4.12'
}

Am I the only one with this issue ?

So, be careful while this dialog appears:

在此输入图像描述

Choose "Remind me later" and NOT "Update"

Stay with the build version you already have.

Incase, you pressed Update, so just rollback your Android Gradle Plugin classpath in build.gradle(project) to below one:

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

This worked for me.

I fought a similar issue and resolved it with the addition of 2 characters ...

And after updating the gradle-wrapper.properties to target 3.2.1 everything was great for me

distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip
If you import external libraries apply  changes for "allprojects"

// 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:2.3.1'

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

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

You should update your Android Studio gradle manually.

1° Step:

Follow this path and get your gradle version

C:\Users\[USER_NAME]\.gradle\wrapper\dists

Here you will get "gradle-XX" (X- is version) in my case it was "gradle-3.3-all"

2° Step:

Go to the following link :

https://services.gradle.org/distributions/

Download your respective version zip file and just past it in the last folder with long random name.

C:\\Users\\[USER_NAME]\\.gradle\\wrapper\\dists\\gradle-xx\\55gk2rcmfc6p2dg9u9ohc31212 HERE

Now open the Android studio, I hope this will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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