什么是摇篮在Android的工作室?摇篮、工作室、Android

2023-09-12 21:32:48 作者:渣渣中渣渣

摇篮是有点混乱给我,也为新的Andr​​oid开发者。谁能解释一下在摇篮Android的工作室是什么,它​​的目的是什么?为什么是包含在Android的工作室摇篮?

Gradle is bit confusing to me and also for new Android developer. Can anyone explain what gradle in Android Studio is and what its purpose is? Why is Gradle included in Android Studio?

推荐答案

摇篮是一个构建系统。

Android的工作室之前,您使用Eclipse进行开发的目的,并有机会,你不知道如何建立你的Andr​​oid APK不使用Eclipse。

Before Android Studio you were using Eclipse for your development purposes, and, chances are, you didn't know how to build your Android APK without Eclipse.

您可以做到这一点在命令行上,但你必须了解每个工具(DX,AAPT)确实在SDK中。 Eclipse中救了我们所有的这些低级别的,但重要的是,基本的细节给予我们自己的编译系统。

You can do this on the command line, but you have to learn what each tool (dx, aapt) does in the SDK. Eclipse saved us all from these low level but important, fundamental details by giving us their own build system.

现在,你有没有想过,为什么 RES 文件夹是在相同的目录的src 文件夹?

Now, have you ever wondered why the res folder is in the same directory as your src folder?

这就是构建系统进入图片。编译系统会自动处理所有的源文件(的.java 的.xml ),然后运用合适的工具(如:需要的Java 类文件,并将其转换成 DEX 文件),和组所有的人都到一个COM pressed文件中,我们敬爱的APK。

This is where the build system enters the picture. The build system automatically takes all the source files (.java or .xml), then applies the appropriate tool (e.g. takes java class files and converts them to dex files), and groups all of them into one compressed file, our beloved APK.

该版本系统使用了一些约定:其中的一个例子是说明包含的源文件(在Eclipse是 \ SRC 文件夹)或资源文件的目录(以Eclipse的是 \ RES 文件夹)。

This build system uses some conventions: an example of one is to specify the directory containing the source files (in Eclipse it is \src folder) or resources files (in Eclipse it is \res folder).

现在,以自动化所有这些任务,必须有一个脚本;您可以在Windows中使用的shell脚本在Linux或批处理文件语法编写自己的编译系统。明白了吗?

Now, in order to automate all these tasks, there has to be a script; you can write your own build system using shell scripting in linux or batch files syntax in windows. Got it?

摇篮是另一个构建系统,是以最好的功能从其他版本系统,并结合成一个。它是基于断了他们的缺点得到改善。 这是一个基于JVM的编译系统,这是什么意思是,你可以编写自己的Java,它的Andr​​oid工作室利用​​的脚本。

Gradle is another build system that takes the best features from other build systems and combines them into one. It is improved based off of their shortcomings. It is a JVM based build system, what that means is that you can write your own script in Java, which Android Studio makes use of.

有关摇篮一个很酷的事情是,它是一个基于插件的系统。这意味着,如果你有自己的编程语言,要自动构建来源的一些包(如JAR为Java的输出),那么你可以写一个完整的插件,Java或Groovy的任务,并将其分发给世界各地。

One cool thing about gradle is that it is a plugin based system. This means if you have your own programming language and you want to automate the task of building some package (output like a JAR for Java) from sources then you can write a complete plugin in Java or Groovy, and distribute it to rest of world.

谷歌看到了市场上最先进的编译系统之一,并意识到你可以写你自己的,很少脚本没有学习曲线,而无需学习Groovy的或任何其他新的语言。所以,他们写了Android插件的摇篮。

Google saw one of the most advanced build systems on the market and realized that you could write scripts of your own with little to no learning curve, and without learning Groovy or any other new language. So they wrote the Android plugin for Gradle.

您必须在您的项目中看到 build.gradle 文件(S)。这就是你可以编写脚本来自动执行任务。你在这些文件中看到的code是Groovy的code。如果你写的System.out.println(你好摇篮!); 然后将打印在控制台上

You must have seen build.gradle file(s) in your project. That is where you can write scripts to automate your tasks. The code you saw in these files is Groovy code. If you write System.out.println("Hello Gradle!"); then it will print on your console.

一个简单的例子是,你有一些文件从一个目录之前,实际的构建过程中发生的复制到另一个。一个摇篮构建脚本可以做到这一点。

A simple example is that you have to copy some files from one directory to another before the actual build process happens. A Gradle build script can do this.

 
精彩推荐
图片推荐