问题
This morning I've updated from SVN my Android project, added some new lines of code and tested: everything work fine.
A couple of minutes later I've tried to run again the application on my device but now Android Studio tells me:
Gradle 'iSfa' project refres failed
Error: protocol family unavailable
The content of build.gradle
is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
packagingOptions {
exclude 'LICENSE'
exclude 'NOTICE'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
defaultConfig {
applicationId "it.gn.sfa"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven {
url "http://JRAF.org/static/maven/2"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v4-r10.jar')
compile files('libs/android-support-v4.jar')
compile 'com.fasterxml.jackson.core:jackson-core:2.3.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
compile 'org.jraf:android-switch-backport:1.3.1'
}
And the content of gradle settings is:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
allprojects {
repositories {
jcenter()
}
}
Note: I'm using the latest version of Android Studio, release 0.8.6, and the latest version of gradle, release 0.12.2.
Deleting the .gradle
folder don't solve anything.
回答1:
Solution found by OP:
Deleting .gradle
folder, turn off Windows' firewall and rebuild project (with a complete download of the gradle repository) worked fine for me.
回答2:
The problem was of a restart required, after deleting everything and then after restart , shut down any firewall working on your system, esp when its handled by an antivirus [ my case: norton internet security] and then opening the same app and rebuilding it, then it shows no error!
回答3:
First make sure you installed last version of Java SE Development Kit.
Then add this enviroment variable to windows variable:
_JAVA_OPTIONS
= -Djava.net.preferIPv4Stack=true;
After these steps, delete .gradle
folder and close and open android studio.
回答4:
I also had this problem and the referenced thread also didn't work for me. What did work was setting _JAVA_OPTIONS environment variable to make Java use IPv4.
_JAVA_OPTIONS = -Djava.net.preferIPv4Stack=true
Reposted this solution for those who dont know how to edit Enviroment variables.
Source: https://www.youtube.com/watch?v=ivSMQ-sZ6sw
来源:https://stackoverflow.com/questions/25603439/gradle-project-refresh-failed-protocol-family-unavailable