Build error android studio 3.1 [英] Build error android studio 3.1

查看:83
本文介绍了Build error android studio 3.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将Android Studio更新到3.1之后,加载新的新模板项目时遇到错误。

I'm experiencing error while loading fresh new template project after updating Android Studio to 3.1.

尝试使用和不使用此选项,但没有用:

Tried with and without this option, but no use:

maven {
    url "https://maven.google.com"
}

在构建过程中,我看到以下消息:

during build, I'm seeing following messages:

Caused by: org.gradle.internal.resolve.ModuleVersionResolveException:
           Could not resolve com.android.tools.build:gradle:3.1.0.
<6 internal calls>
   ... 128 more
Caused by: org.gradle.api.resources.ResourceException:
           Could not get resource 'https://dl/google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom' <21 internal calls>
   ... 133 more
Caused by: org.gradle.internal.resource.transport.http.HttpRequestException:
           Could not GET 'https://dl/google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom'. <16 internal calls>
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to dl.google.com:433 [dl.google.com/216.58.199.142] failed

build.gradle

apply plugin: 'com.android.application'

android {
  compileSdkVersion 27
  buildToolsVersion "27.0.3"
  defaultConfig {
    applicationId "com.example.am.myapplicationtest"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    //testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }

参考屏幕截图:

Screenshots for reference:

渐变设置

推荐答案

这是网络问题



我认为您的问题是由错误的网络引起,原因是:

This is a network issue

I think your problem is caused by bad network, since:

Caused by: org.apache.http.conn.HttpHostConnectException:
Connect to dl.google.com:433 [dl.google.com/216.58.199.142] failed

我面对类似的问题,最后我发现根本原因是gradle的默认代理(不是Android Studio而是gradle!)

I face a similar problem, and at last I found the root cause is the default proxy of gradle(NOT for Android Studio but for gradle!)

我在中定义了自己的代理设置 gradle.properties ,但是当我在Android Studio中单击同步时,我的设置不适用,并导致如下错误:

I defined my own proxy settings in gradle.properties, but when I click sync in Android Studio, my settings does not apply and result in a error like this:

Error:Failed to resolve: com.android.support:appcompat-v7:27.0.1
Install Repository and sync project
Open File
Show in Project Structure dialog



解决方案



最后,我通过命令行构建应用程序并自行设置代理来解决问题,如下所示:

Solution

At last I solved my problem by build my application by command line and set proxy myself, like this:

gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129

Gradle代理配置中获取,感谢Guillaume Berche。

Get this from Gradle proxy configuration, Thanks to Guillaume Berche.

这篇关于Build error android studio 3.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆