This message was deleted.
# android
s
This message was deleted.
c
I was going to say yes, but 3.a is 🤯
e
gradlew doesn't do downloading itself. it uses Java to launch gradle-wrapper.jar which downloads and executes the Gradle distribution listed in properties
then Gradle evaluates the build scripts, including downloading plugins such as AGP, to build a model, and uses that to determine how to build your project
x
Note that Studio (or IntelliJ) does not use
gradlew
or
gradle-wrapper.jar
because it includes Gradle's Tooling API which is a Jar that basically does the same thing. That allows the IDE to directly start the Gradle daemon and connect to it without starting another JVM just to run
gradle-wrapper
.
so
gradlew
and
gradle-wrapper.jar
are only used from the command line. The IDE only uses the content of
gradle-wrapper.properties
👍 2
v
Adding to this question is there a relationship between Gradle distribution and AGP version ? i.e. If I’m using AGP 8.0.0-alpha06 in build.gradle is there a min distribution version to be set ?
so
gradlew
and
gradle-wrapper.jar
are only used from the command line. The IDE only uses the content of
gradle-wrapper.properties
not totally true, the IDE launches
gradlew
directly as well. https://android-developers.googleblog.com/2022/01/android-studio-bumblebee-202111-stable.html
we’ve introduced a new test runner to Android Gradle plugin (AGP) 7.1.0 that Android Studio Bumblebee uses by default when running instrumentation tests, so all your tests run through a unified test runner. This is a similar improvement to Android Studio Arctic Fox, where we started running all unit tests via Gradle by default.
a
@CristianGM what caused the 🤯? the correctness or the incorrectness of analogy? I have explored android/java/cs dev for a very few time, so please correct if am wrong😅 @ephemient so why can't we/OS start the
gradle-wrapper.jar
by ourselves, like
java -jar gradle-wrapper.jar build
? what is the exact use of
gradlew
/`gradlew.bat`? @Xavier Ducrohet I have a related question to this. why does AndroidStudio gives warning like build path and jdk path are different, and will result in spawning multiple JVMs? at the OS level, i can assume that if i have a jar named
print-hello-world.jar
and
print-bye-world.jar
each of size 1mb, then when i run the both of these jar, they will be take 1.001 gb of RAM memory while their process is executing( i.e 1gb of JVM(assumption)+ 1mb of jar file), and that can't be avoided, right? or could it be? is AS telling a warning that it can somehow share the common jvm in multiple processes?
PS: Sorry for the late replies, having a lot of stuff in plate right now. Thank you for helping me on this query
e
you could launch
gradle-wrapper.jar
yourself, the
gradlew
script is there to help set up the environment for it
but
gradle-wrapper.jar
isn't what's doing most of the work: its job is to download and cache the gradle distribution if needed, launch the gradle daemon if needed, and forward the build commands to the daemon / forward the output from the daemon to your console
the daemon will remain in the background after a build (unless it is instructed not to) and can be re-used between launches if its JVM, properties, and other environmental factors are the same
x
not totally true, the IDE launches
gradlew
directly as well.
That's not correct. All IDE actions that call into Gradle use Gradle's tooling API which does not use
gradlew
why does AndroidStudio gives warning like build path and jdk path are different
When Studio calls into Gradle using the Tooling API, it specify which JRE/JDK to use to run Gradle. By default it'll use the one embedded into Studio (which Studio uses to run itself). When running from the command line,
gradlew
will use whatever JDK path is set as default in your env properties. If they are different it means that starting build from the IDE and the command line will use different JDK and therefore the daemon started by one cannot be reused by the second one. daemon have a idle timeout of 3 hour, so they'll linger for that long after the last build before they die.
x
This class is in the
gradle-core
module which is the AGP plugin, not the IDE.
I was going to say it's likely used to call into
adb
but I just commented it out (IJ wouldn't show me any usage) and it is indeed unused!
e
maybe a leftover from another time, then