问题
I'm trying to create my first project in android studio, I'm on a mac, FYI. When I build settings.gradle, I get a failed build. Note: Please don't mark this as a duplicate, see below I have links to two other SO questions that didn't fix the problem.
My settings.gradle file contents:
include ':app'
, but I've also tried include 'app'
based on the advise here, with no difference in result.
The Gradle Console ends with BUILD SUCCESSFUL
, but the debug window shows BUILD FAILED
:
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:57079,suspend=y,server=n "-Dgradle.home=/Applications/Android Studio.app/Contents/gradle/gradle-2.10" -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/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:/Applications/Android 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-base-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-play-2.10.jar:/Applications/Android 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:/Applications/Android 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:/Applications/Android 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-builders-2.10.jar:/Applications/Android 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]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined. Connected to the target VM, address: '127.0.0.1:57079', transport: 'socket'
FAILURE: Build failed with an exception.
Where: Build file '/Users/username/AndroidStudioProjects/myProject/settings.gradle' line: 1
What went wrong: A problem occurred evaluating root project 'myProject'.
Could not find method include() for arguments [:app] on root project 'myProject'.
- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.952 secs Disconnected from the target VM, address: '[obscuredIP]:57079', transport: 'socket'
Process finished with exit code 1
Per the advise here, I have done ./gradlew assembleRelease
both in android studio's terminal and in my mac's terminal. in Android Studio terminal, I get a successful build, but on the mac's terminal, I get:
$ ./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
In case it helps, this is the output on mac's terminal for ./gradlew tasks --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
回答1:
Use the Analyze->Inspect Code menu to show code inspection issues. In this case, the problem was that the build.gradle file was referencing a different compilesdkversion than other places in the project.
Analyze->Inspect Code is very useful, use it!
回答2:
It looked like the Android studio had bad settings of current project. In my case it looked like it had setting from othre project. The dependencies of project properties (Ctr+Shift+S) was diffrent from dependecies in build.gradle file. (Analyse showed me nothing wrong and from console it worked). I just:
- closed the project
- removed the .gradle, .idea and build directory
- and opened project again.
After that, it builds project without problem.
来源:https://stackoverflow.com/questions/38544093/could-not-find-method-include-for-arguments-app-on-root-project-myproject