Android Studio 0.5.2 Gradle Refresh Project失败

时间:2014-03-16 12:54:54

标签: android gradle android-studio android-gradle

更新我的活动日志

最后编辑 在尝试了所有可能的解决方案后,我发现我已经完全安装了Windows。这样做我注意到这是一个防火墙问题,我的防病毒软件阻止了studio64.exe process.

我刚刚安装了Android Studio 0.4.2,然后立即更新到0.5.2而无需打开或创建任何新项目。

我更新了Android SDK然后创建了一个新项目。即使我试图更改本地gradle分发,我仍然收到Gradle Refresh失败的错误,似乎没有任何工作,我尝试Gradle回复的所有内容:“请修复您的Gradle配置”...

这件事发生在我身上,因为我从未更新到Android工作室5.1。

我尝试使用Gradle 1.10和1.11以及可从网站http://developer.android.com/sdk/installing/studio.html下载的安装工具包中包含的Gradle包装器

以下是我的gradle文件:

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'])
}

外部的build.gradle文件。

// 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()
    }
}

现在我尝试从Canary Build下载最新版本,然后单独下载SDK,仍然是同样的问题,这真的很烦人......有没有网络设置我可能设置不正确?

目前我正在使用Android Studio的默认grale包装器,这是我得到的错误:

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

尝试使用:gradlew.bat --stacktrace assemble

编译项目后

这就是我得到的:

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>

还尝试从我的项目中删除.gradle和gradle文件。似乎没什么用。

编辑到目前为止,似乎对我有用的是将服务目录.gradle替换为您的根目录,因为似乎该目录可能存在路径问题。让我知道这是否为你解决了它!

3 个答案:

答案 0 :(得分:8)

轻松修复!

defaultConfig文件的build.gradle部分需要进入buildTypes,如下所示:

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'])
}

请参阅Migrating from 0.8 to 0.9指南。

此外,请确保您使用的是最新的Gradle分发网址(如果您正在使用Gradle包装器)。

gradle-wrapper.properties文件中,应该是以下行:

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

最后确保在再次构建之前clean您的项目(Build - > Clean Project)。

答案 1 :(得分:4)

在我的情况下,我已经尝试过上面的这两个解决方案,但两者都无法解决问题,最后我关闭了我的AVAST安全软件......然后它工作了! gradle sync是好的.. 虽然我不知道为什么,但关闭AVAST确实解决了这个问题。

答案 2 :(得分:3)

我有完全相同的问题。

要解决这个问题,只需在Android Studio 0.5.2中创建另一个项目,之后新项目完全创建并构建关闭它并打开旧项目(项目' ClujTourist ')。现在您可以成功构建ClueTourist。

如果出现任何问题,请告诉我。