导入项目时Android Studio中的Gradle同步错误

时间:2015-04-11 09:10:31

标签: android android-studio gradle android-gradle

我正在尝试运行此open source project from github。我在gradle中收到此错误。我在“管理员模式”下运行Android工作室。当我点击“再试一次”时,它开始下载gradle-2.2.1-all.zip,所以转到this site并下载了gradle-2.2.1-all.zip并将其解压缩到

  

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

Android Studio中的

错误。

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$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.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$2.execute(ExternalSystemUtil.java:406)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:483)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:471)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.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$8.run(ProgressManagerImpl.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.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$1$1.run(ApplicationImpl.java:149)

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

4 个答案:

答案 0 :(得分:30)

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

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

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

答案 1 :(得分:12)

我认为该网站https://services.gradle.org/distributions/错误地配置了ssl证书问题。用于该域的证书不适合域名。 Not trusted certificate

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

答案 2 :(得分:2)

我刚遇到同样的问题。

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

Google Public DNS

例如,您可以使用Google Public DNS 8.8.8.8 8.8.4.4

OpenDNS的

OpenDNS是另一种选择。

答案 3 :(得分:0)

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