无法在根项目' myProject'

时间:2016-07-23 16:40:14

标签: android-studio gradlew

我试图在Android工作室创建我的第一个项目,我在Mac上,我是。当我构建settings.gradle时,我得到了一个失败的构建。 注意:请不要将此标记为重复,请参阅下文我链接到其他两个没有解决问题的SO问题。

我的settings.gradle文件内容: include ':app',但我也根据建议here尝试include 'app',但结果没有差异。

Gradle控制台以BUILD SUCCESSFUL结尾,但调试窗口显示BUILD FAILED

  

/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java   -agentlib:JDWP =运输= dt_socket,地址127.0.0.1 =:57079,暂停= Y,服务器=正   " -Dgradle.home = /应用/ Android的   Studio.app/Contents/gradle/gradle-2.10"   -Dtools.jar = /图书馆/的Java / JavaVirtualMachines / jdk1.7.0_79.jdk /内容/首页/ lib中/的tools.jar   -javaagent:/Users/username/Library/Caches/AndroidStudio2.1/groovyHotSwap/gragent.jar   -Dfile.encoding = UTF-8 -classpath" / Applications / Android Studio.app/Contents/gradle/gradle-2.10/lib/groovy-all-2.4.4.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/ant-1.9.3.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/ant-launcher-1.9.3.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-base-services-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-base-services-groovy-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-cli-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-core-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-docs-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-launcher-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-messaging-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-model-core-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-model-groovy-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-native-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-open-api-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-resources-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-tooling-api-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-ui-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/gradle-wrapper-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-announce-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-antlr-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-build-comparison-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-build-init-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-code-quality-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-dependency-management-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-diagnostics-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-ear-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-ide-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-ide-native-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-ivy-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-jacoco-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-javascript-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-jetty-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-language-groovy-2.10.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-language- Java的2.10.jar:/应用/安卓   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-language-jvm-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-language-native-2.10.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-language- scala-2.10.jar:/ Applications / Android Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-maven-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-osgi-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-platform-b​​ase-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-platform-jvm-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-platform-native-2.10.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-platform-播放2.10.jar:/应用/安卓   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-plugin-development-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-plugin-use-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-plugins-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-publish-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-reporting-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-resources-http-2.10.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-resources- s3-2.10.jar:/应用/安卓   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-resources-sftp-2.10.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-scala- 2.10.jar:/应用/安卓   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-signing-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-sonar-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-test-kit-2.10.jar:/Applications/Android   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-testing-native-2.10.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.10/lib/plugins/gradle-tooling- API建设者-2.10.jar:/应用/安卓   Studio.app/Contents/gradle/gradle-2.10/lib/plugins/ivy-2.2.0.jar:/Applications/Android   Studio.app/Contents/lib/idea_rt.jar" org.gradle.launcher.GradleMain   --build-file /Users/username/AndroidStudioProjects/myProject/settings.gradle   objc [64642]:类JavaLaunchHelper在两者中实现   /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java   和   /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/libinstrument.dylib。   将使用两者之一。哪一个未定义。连接到   目标虚拟机,地址:' 127.0.0.1:57079',传输:' socket'

     

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

     
      
  • 其中:构建文件' /Users/username/AndroidStudioProjects/myProject/settings.gradle'   line:1

  •   
  • 出了什么问题:评估根项目' myProject'时出现问题。

  •   
     

无法在根项目' myProject'上找到参数[:app]的方法include()。

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

建立失败

     

总时间:0.952秒   断开与目标VM的连接,地址:' [obscuredIP]:57079',transport:' socket'

     

使用退出代码1完成处理

根据建议here,我已经在android studio的终端和我的mac终端中完成了./gradlew assembleRelease。在Android Studio终端中,我获得了成功的构建,但在mac的终端上,我得到了:

$ ./gradlew assembleRelease --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
Task 'assembleRelease' not found in root project 'username'.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.execution.TaskSelectionException: Task 'assembleRelease' not found in root project 'username'.
    at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:100)
    at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:75)
    at org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineTaskParser.java:42)
    at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:44)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
    at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
    at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
    at org.gradle.execution.DefaultBuildConfigurationActionExecuter.select(DefaultBuildConfigurationActionExecuter.java:36)
    at org.gradle.initialization.DefaultGradleLauncher$3.run(DefaultGradleLauncher.java:143)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:140)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)


BUILD FAILED

Total time: 0.682 secs

如果有帮助,这是./gradlew任务的mac终端输出--all:

$ ./gradlew tasks --all
:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'username'.
components - Displays the components produced by root project 'username'. [incubating]
dependencies - Displays all dependencies declared in root project 'username'.
dependencyInsight - Displays the insight into a specific dependency in root project 'username'.
help - Displays a help message.
model - Displays the configuration model of root project 'username'. [incubating]
projects - Displays the sub-projects of root project 'username'.
properties - Displays the properties of root project 'username'.
tasks - Displays the tasks runnable from root project 'username'.

BUILD SUCCESSFUL

Total time: 0.674 secs

2 个答案:

答案 0 :(得分:0)

使用Analyze-> Inspect Code菜单显示代码检查问题。在这种情况下,问题是build.gradle文件引用的是与项目中其他位置不同的compilesdkversion。

分析 - >检查代码非常有用,请使用它!

答案 1 :(得分:0)

看起来Android工作室的当前项目设置不好。在我的情况下,它似乎有来自其他项目的设置。项目属性(Ctr + Shift + S)的依赖项与build.gradle文件中的依赖项不同。 (分析显示我没有任何错误,并从控制台工作)。我只是:

  1. 关闭了项目
  2. 删除了.gradle,.idea和build目录
  3. 再次打开项目。
  4. 之后,它可以毫无问题地构建项目。