Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 0.5.2 Gradle Refresh Project failed

UPDATED WITH MY EVENT LOG

LAST EDIT After trying out every possible solution i could find i've come to a fresh install of Windows. Doing this i noticed that this was indeeed a firewall issue, my antivirus was blocking the studio64.exe process.

I have freshly installed Android Studio 0.4.2 then immediately updated to 0.5.2 without opening or creating any new projects.

I updated the Android SDK then created a new project. I keep getting the error with the Gradle Refresh Failed even though i tried to change the local gradle distribution, nothing seems to work, everything i try Gradle replies with: "Please fix your Gradle configuration"...

This had happened to me since i updated to Android studio 5.1, never before.

I tried with Gradle 1.10 and 1.11 and the Gradle wrapper included in the install kit downloadable from the website http://developer.android.com/sdk/installing/studio.html

Here are my gradle files:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

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

And the outside build.gradle file.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

Now i've tried downloading the latest version from the Canary Build and then downloading the SDK sepparately, still the same issue, this is really annoying... is there any network setting i might be having setup incorrectly?

Currently i am using the default grale wrapper from Android Studio, and this is the error i get:

10:58:37 AM Gradle 'ClujTourist' project refresh failed:
            A fatal exception has occurred. Program will exit.
            : Gradle settings

After trying to compile the project with: gradlew.bat --stacktrace assemble

this is what i got:

C:\Users\Adrian-PC\AndroidStudioProjects\ClujTourist>gradlew.bat --stacktrace as
semble

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'ClujTourist'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not find any version that matches com.android.tools.build:gradle:0.11
.+.
     Required by:
         :ClujTourist:unspecified

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring roo
t project 'ClujTourist'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigu
rationFailure(LifecycleProjectEvaluator.java:79)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(L
ifecycleProjectEvaluator.java:57)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:507)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:82)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuil
dConfigurer.java:31)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:142)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:113)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:81)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:64)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.jav
a:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:201)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:174)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:139)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:46)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.Main.main(Main.java:37)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:50)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:32)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.ja
va:33)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all depe
ndencies for configuration ':classpath'.
        at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfigurat
ion.rethrowFailure(DefaultLenientConfiguration.java:52)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfigura
tion.rethrowFailure(DefaultResolvedConfiguration.java:36)
        at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyR
esolver$FilesAggregatingResolvedConfiguration.rethrowFailure(SelfResolvingDepend
encyResolver.java:106)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDep
endencyResolver$ErrorHandlingResolvedConfiguration.rethrowFailure(ErrorHandlingA
rtifactDependencyResolver.java:176)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:465)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
.getFiles(DefaultConfiguration.java:202)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
_Decorated.getFiles(Unknown Source)
        at org.gradle.api.internal.initialization.DefaultScriptHandler.updateCla
ssPath(DefaultScriptHandler.java:75)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.
apply(DefaultScriptPluginFactory.java:145)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildSc
riptProcessor.java:38)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildSc
riptProcessor.java:25)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.eva
luate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(L
ifecycleProjectEvaluator.java:55)
        ... 28 more
Caused by: org.gradle.api.internal.artifacts.ivyservice.ModuleVersionNotFoundExc
eption: Could not find any version that matches com.android.tools.build:gradle:0
.11.+.
Required by:
    :ClujTourist:unspecified
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LazyDependenc
yToModuleResolver$DynamicVersionResolveResult.notFound(LazyDependencyToModuleRes
olver.java:170)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LazyDependenc
yToModuleResolver$AbstractVersionResolveResult.resolve(LazyDependencyToModuleRes
olver.java:91)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LazyDependenc
yToModuleResolver.resolve(LazyDependencyToModuleResolver.java:47)
        at org.gradle.api.internal.artifacts.ivyservice.VersionForcingDependency
ToModuleResolver.resolve(VersionForcingDependencyToModuleResolver.java:48)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.Dependency
GraphBuilder$ModuleVersionSelectorResolveState.resolveModuleRevisionId(Dependenc
yGraphBuilder.java:935)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.Dependency
GraphBuilder$DependencyEdge.resolveModuleRevisionId(DependencyGraphBuilder.java:
296)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.Dependency
GraphBuilder.traverseGraph(DependencyGraphBuilder.java:93)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.Dependency
GraphBuilder.resolve(DependencyGraphBuilder.java:66)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDep
endencyResolver$1.transform(DefaultDependencyResolver.java:108)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDep
endencyResolver$1.transform(DefaultDependencyResolver.java:77)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager
.withIvy(DefaultIvyContextManager.java:61)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDep
endencyResolver.resolve(DefaultDependencyResolver.java:77)
        at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDepe
ndencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:39)
        at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDepe
ndencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:37)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAcc
ess.java:148)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(De
faultPersistentDirectoryStore.java:123)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManag
er.useCache(DefaultCacheLockingManager.java:77)
        at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDepe
ndencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:37)
        at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyR
esolver.resolve(SelfResolvingDependencyResolver.java:41)
        at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigs
ArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDependencyRes
olver.java:46)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDep
endencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:44)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationReso
lver.resolve(DefaultConfigurationResolver.java:42)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
.resolveNow(DefaultConfiguration.java:240)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
.getResolvedConfiguration(DefaultConfiguration.java:230)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
_Decorated.getResolvedConfiguration(Unknown Source)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:463)
        ... 36 more


BUILD FAILED

Total time: 7.864 secs

C:\Users\Adrian-PC\AndroidStudioProjects\ClujTourist>

Also tried to delete the .gradle and gradle files from my project. Nothing seems to work.

EDIT What seems to be working for me so far is replacing the service directory .gradle to your root directory as it seems there might have been a path problem to that directory. Let me know if this solved it for you!

like image 316
Adrian Olar Avatar asked Mar 16 '14 12:03

Adrian Olar


Video Answer


3 Answers

Easy fix!

The defaultConfig part of your build.gradle file needs to go inside buildTypes, like this:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"


    buildTypes {
        defaultConfig {
            minSdkVersion 8
            targetSdkVersion 19
            versionCode 1
            versionName "1.0"
        }

        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

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

See the guide for Migrating from 0.8 to 0.9.

Furthermore, make sure you're using the up-to-date Gradle distribution url (if you're using the Gradle wrapper).

In your gradle-wrapper.properties file should be the following line:

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

Finally make sure you clean your project before building again (Build -> Clean Project).

like image 154
Matt Logan Avatar answered Oct 19 '22 23:10

Matt Logan


In my case, I have tried these two solutions above, but neither could solve the problem, finally I shut down my AVAST safety software...then It worked! gradle sync is ok.. Although I don't know why, but shutting down AVAST did solve the problem.

like image 40
lei jia Avatar answered Oct 19 '22 23:10

lei jia


I had exactly the same problem.

To solve that just create another project in Android Studio 0.5.2 and after that when new project completely Created and Built close it and open your old project (project 'ClujTourist' ). Now you can build ClueTourist successfully.

Please let me know if anything goes wrong.

like image 34
Maziar Aboualizadehbehbahani Avatar answered Oct 19 '22 23:10

Maziar Aboualizadehbehbahani