In my case when I will run this below command
./gradlew -q projects
It will return output as below
Root project 'MyProject'
+--- Project ':app'
\--- Project ':mymodule'
now I want to build(Run/Green Play icon for the app) my ':app'
so ':mymodule'
should build automatically but without including the ':mymodule'
as a dependency in ':app'
level build.gradle
something like this in app level build.gradle file
task gradleBuild(type: GradleBuild ) {
println "gradleBuild task start"
doFirst{
tasks=["mymodule:clean"]
tasks = ["mymodule:build"]
}
doLast {
tasks = ["mymodule:install"]
println 'gradleBuild task end.'
}
}
build.dependsOn gradleBuild
But it not working I am getting the error message as below
Task :app:gradleBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Project 'mymodule' not found in project ':MyProject:app'.
In settings.gradle
I have this
include ':app' , ':mymodule'
Your requirement of automatically building the library project("mymodule" in your case) without including it in the app module build.gradle file, when we press "Run/green Play " icon can be achieved with below approach.
Generally Run icon will be configured for single configuration. This is not at project scope, it is at module scope. Because of this reason, when you press icon, "mymodule" is not built, whereas if you invoke 1. gradlew build from command line 2. Sync Project 3. click on Make Project
both the modules(app & mymodule) are built.
To achieve your requirement, we have to edit the existing app configuration in Android studio to build the "mymodule" lib project.
task buildModule(type: GradleBuild) { buildFile = '../mymodule/build.gradle' tasks = ['build'] }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.