Gradle 导入项目时 Android studio 出现同步错误

Gradle sync error in Android studio when importing project

我正在尝试 运行 这个 open source project from github. I am getting this error in gradle. I am running Android studio in "Administrator mode". When i click on "try again" it starts downloading gradle-2.2.1-all.zip so went to this site 并确实下载了 gradle-2.2.1-all.zip 并将其解压缩到

C:\Program Files\Android\Android Studio\gradle\

Android 工作室出错。

Gradle 'nfctasker-master' project refresh failed
Error:No subject alternative DNS name matching services.gradle.org found.

Build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}
apply plugin: 'com.android.application'

repositories {
    jcenter()
}

android {
    compileSdkVersion 20
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "net.ruinnel.nfc.tasker"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.+'
    compile 'com.android.support:appcompat-v7:21.+'
}

这是日志中的错误

2015-04-11 15:12:47,496 [2705228]   WARN - nal.AbstractExternalSystemTask - No subject alternative DNS name matching services.gradle.org found. 
com.intellij.openapi.externalSystem.model.ExternalSystemException: No subject alternative DNS name matching services.gradle.org found.
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
    at org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:153)
    at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:358)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:151)
    at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:322)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:367)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:333)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:203)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:116)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:64)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.execute(ExternalSystemUtil.java:406)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.run(ExternalSystemUtil.java:483)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:471)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
    at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:149)

我是 Android 工作室的新手 我无法理解错误的含义,也无法在互联网上找到任何内容。请帮助我。抱歉英语不好。

我刚遇到同样的问题

请更改您的 DNS 服务器设置并重新连接到 Internet。然后,再次尝试 Gradle 同步。

Google Public DNS

例如,您可以使用 Google Public DNS,即 8.8.8.88.8.4.4

OpenDNS

OpenDNS是备选方案。

作为临时解决方法,您可以在 http 上下载 Gradle 而不是 https

编辑gradle/wrapper/gradle-wrapper.properties, 应该在项目的根目录下可用,并将 distributionUrl 更改为:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip

我认为站点 https://services.gradle.org/distributions/ 有错误配置的 ssl 证书问题。用于该域的证书不是该域名的正确证书。

我认为你应该等到Gradleware修复它,同时,你可以暂时使用Emanuel的解决方法。

只需在 gradle 设置中添加此行即可更新您的服务 distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip