android studio3.x 问题:构建项目失败

issue with android studio3.x : build project failed

打扰一下,我才刚刚开始学习 android 开发。

我已经安装了android studio 3.2,并创建了一个新项目。没有编辑,得到这个。

我用谷歌搜索了很多,并尝试过:

  1. 未勾选settings-->gradle-->offline work
  2. 选中以启用嵌入式 Maven 存储库
  3. 已添加maven { url 'http://repo1.maven.org/maven2' }
  4. 将 AS 更新到最新的 3.2.1

还是不行..

build.gradle

buildscript {

repositories {
    //maven { url 'http://repo1.maven.org/maven2' }
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'


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

allprojects {
  repositories {
    google()
    jcenter()
  }
}

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

app/build.gradle

apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
    applicationId "com.my.testapp.activitylifecycletest"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

非常感谢!

同样的情况,您可以检查您的代理设置。 在您的 gradle/gradle-wrapper.properties 文件中添加如下代理设置

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080