Android Studio 0.4.3 - 在根项目中找不到任务'组合'

时间:2014-01-26 14:55:50

标签: android android-studio android-gradle

前几天更新到0.4.3并尝试启动一个新项目,甚至没有使用现有项目,我收到此错误:

  

失败:构建因异常而失败。

     
      
  • 出了什么问题:在根项目'XXX'中找不到任务'assemble'。

  •   
  • 尝试:运行gradle任务以获取可用任务列表。使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。

  •   

这是我在日志文件中找到的内容:

2014-01-26 09:50:18,186 [ 276355]   WARN - nal.AbstractExternalSystemTask - com.android.builder.model.SourceProvider.getAidlDirectories()Ljava/util/Collection; 
com.intellij.openapi.externalSystem.model.ExternalSystemException: com.android.builder.model.SourceProvider.getAidlDirectories()Ljava/util/Collection;
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:185)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:113)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:61)
    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$3.execute(ExternalSystemUtil.java:471)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:549)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
    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:373)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:420)
    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:150)

这是我的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.8.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

我在网上查了几篇帖子,但到目前为止还没有。任何帮助将不胜感激。

7 个答案:

答案 0 :(得分:24)

快速回答

删除所有内容并包含组件标记

<component name="FacetManager"> 
   ... <!-- remove all in this node 
</component>` 

长答案

请参阅http://tools.android.com/knownissues

  

如果收到以下错误消息:

Gradle: 
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'assemble' not found in root project 'MyProject'.
* Try:
Run gradle tasks to get a list of available tasks.
  

真正的问题是以前版本的Android Studio   错误配置了IDEA文件(例如MyProject.iml) - 它增加了一个额外的   "<component name="FacetManager">"不应该是的XML元素   目前,
  在上面的例子中,解决方案是编辑&#34; MyProject.iml&#34;   并删除整个节点 <component name="FacetManager"> ... </component>

如果您的特定项目名为XXX,则您需要更正名为XXX.iml的文件

文档还说&#34;您也可以删除项目的.idea文件夹和iml文件,然后将您的源重新导入到新的Android Studio项目中。&#34;并不是说这个解决方案对你有用,因为你甚至无法建立一个新的项目。

答案 1 :(得分:8)

这对我有用。打开根 build.gradle 文件。

将此添加为第一行:task assemble{}

答案 2 :(得分:2)

我不得不回滚到Android 0.3.2才能使用0.4.3版本无法正常工作。到目前为止,一切都运转正常。

答案 3 :(得分:2)

我正在分享我如何解决它 - 如果您删除了一个库。您还需要记住将其从settings.gradle文件中删除。否则它可能通过命令行而不是通过android studio

成功构建

答案 4 :(得分:1)

您可能需要在子项目中添加settings.gradle。

settings.gradle文件应放置在项目的根目录下,并且至少包含以下行:

include ':app'

参考: https://georgik.rocks/missing-run-or-debug-action-in-android-studio/

答案 5 :(得分:0)

尝试运行新版本的gradle

$("#emailaddress").val()

document.getElementById('emailaddress').value

它将创建初始build.gradle。要查看所有gradle命令,请运行

$ gradle init

答案 6 :(得分:0)

仅通过重建项目,它就对我有用。

  

构建->重建项目