21

I am trying to run this 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 and did download gradle-2.2.1-all.zip and have extract it to

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

error in 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.+'
}

this is the error from log

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)

I am new to Android studio I am not able to understand what error means nor i am able to find anything on internet. Pleas help me. Sorry for bad english.

Sam
  • 1,237
  • 1
  • 16
  • 29
  • Please post your build.gradle(project level). – Shvet Apr 11 '15 at 09:17
  • @Shvet I have added it.I am new to Android studio so let me know if it not project level one – Sam Apr 11 '15 at 09:19
  • if you will check there are 2 gradle file one is for whole project and one is for module and it is written in `build.gradle(here)`. – Shvet Apr 11 '15 at 09:21
  • i see. So one i posted was correct right? – Sam Apr 11 '15 at 09:29
  • yes. there is no problem in your gradle file. it is correct. error is from server to download it. your firewall may be trying to block it. – Shvet Apr 11 '15 at 09:31
  • I dont have any firewall and anti-virus is disabled as well. Also i am running in administrator mode just to be on safe side. – Sam Apr 11 '15 at 09:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/74996/discussion-between-shvet-and-user3933143). – Shvet Apr 11 '15 at 09:39
  • I just have the same problem, please update if you find a solution :) – George Apr 11 '15 at 09:44
  • This worked for me: http://stackoverflow.com/questions/29576097/gradle-sync-error-in-android-studio-when-importing-project (removing the .gradle folder) – George Apr 11 '15 at 09:53
  • @George delete .grade from the project? – Sam Apr 11 '15 at 09:59
  • I deleted the main one, the one that was installed in my home directory. (well, deleted = copied it to another directory) – George Apr 11 '15 at 10:06
  • I am using Emanuel Fonseca's method and it is working currently. – Sam Apr 11 '15 at 10:15
  • possible duplicate of [Can't build Android App with Gradle](http://stackoverflow.com/questions/29576871/cant-build-android-app-with-gradle) – Tom Anderson Apr 11 '15 at 13:54

4 Answers4

30

As a temporary workaround you may download Gradle over http instead of https.

Edit gradle/wrapper/gradle-wrapper.properties, that should be available at the root of your project, and change distributionUrl to:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Igl3
  • 4,900
  • 5
  • 35
  • 69
edfonseca
  • 330
  • 3
  • 6
  • I am using your method and AS is downloading gradle so waiting for it to finished downloading. Will post the status after that. – Sam Apr 11 '15 at 10:11
  • This is working for me. I guess when the certificate has been fixed, I'll update it back to https – bcpettifer Apr 11 '15 at 10:56
  • This method is perfect. It worked. The official link to gradles doesnt have https, instead it is http still Android Studio uses https – Sam Apr 11 '15 at 11:01
  • As a reminder, this might be a good thing to add to a `git stash` operation so you don't always leave it this way. Awesome catch for what was busted. – Wyatt Apr 11 '15 at 21:07
11

I think the site, https://services.gradle.org/distributions/ has wrongly configured ssl certificate issue. The certificate used for that domain is not a proper one for the domain name. Not trusted certificate

I think you should wait until Gradleware fixes it, and in the meantime, you can temporarily use Emanuel's workaround.

Kevin Lee
  • 632
  • 6
  • 4
  • By the way, I had asked Gradleware about this issue before putting my answer here as I'm having the same one. I hope they'll fix it soon. – Kevin Lee Apr 11 '15 at 10:57
  • hope they fix it soon. Thanks for the help. – Sam Apr 11 '15 at 11:05
  • @user3933143 FYI, I think the certificate issue has been fixed. I no longer have this problem. I guess you should be fine now too. – Kevin Lee Apr 11 '15 at 23:46
2

I just encountered the same problem.

Please change your DNS server setting and reconnect to the Internet. Afterwards, try Gradle sync again.

Google Public DNS

For example, you can make use of the Google Public DNS, which is 8.8.8.8 and 8.8.4.4.

OpenDNS

OpenDNS is an alternative.

Gavin
  • 4,458
  • 3
  • 24
  • 37
  • 1
    I did change it google dns and flush dns using ipconfig/flushdns but it is still not working. – Sam Apr 11 '15 at 09:55
0

Just add this line in gradle setting so that your service can be update distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip