http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Android-tasks
Gradle Plugin User Guide
Contents
IntroductionGoals of the new Build System
The goals of the new build system are:
Gradle is an advanced build system as well as an advanced build toolkit allowing to create custom build logic through plugins.
Here are some of its features that made us choose Gradle:
Requirements
Basic ProjectA Gradle project describes its build in a file called build.gradle located in the root folder of the project.
Simple build filesThe most simple Java-only project has the following build.gradle:
apply plugin: 'java' This applies the Java plugin, which is packaged with Gradle. The plugin provides everything to build and test Java applications. The most simple Android project has the following build.gradle:
buildToolsVersion "19.0.0" } There are 3 main areas to this Android build file:
buildscript { ... } configures the code driving the build. In this case, this declares that it uses the Maven Central repository, and that there is a classpath dependency on a Maven artifact. This artifact is the library that contains the Android plugin for Gradle in version 0.11.1 Note: This only affects the code running the build, not the project. The project itself needs to declare its own repositories and dependencies. This will be covered later. Then, the android plugin is applied like the Java plugin earlier. Finally, android { ... } configures all the parameters for the android build. This is the entry point for the Android DSL. By default, only the compilation target, and the version of the build-tools are needed. This is done with thecompileSdkVersion and buildtoolsVersion properties. The compilation target is the same as the target property in the project.properties file of the old build system. This new property can either be assigned a int (the api level) or a string with the same value as the previous target property.
Important: You should only apply the android plugin. Applying the java plugin as well will result in a build error. Note: You will also need a local.properties file to set the location of the SDK in the same way that the existing SDK requires, using the sdk.dir property. Alternatively, you can set an environment variable called ANDROID_HOME. There is no differences between the two methods, you can use the one you prefer. The basic build files above expect a default folder structure. Gradle follows the concept of convention over configuration, providing sensible default option values when possible.
The basic project starts with two components called “source sets”. The main source code and the test code. These live respectively in:
Inside each of these folders exists folder for each source components.
For both the Java and Android plugin, the location of the Java source code and the Java resources:
For the Android plugin, extra files and folders specific to Android:
Configuring the StructureWhen the default project structure isn’t adequate, it is possible to configure it. According to the Gradle documentation, reconfiguring the sourceSets for a Java project can be done with the following:
} resources { srcDir 'src/resources' } } Note: srcDir will actually add the given folder to the existing list of source folders (this is not mentioned in the Gradle documentation but this is actually the behavior). To replace the default source folders, you will want to use srcDirs instead, which takes an array of path. This also shows a different way of using the objects involved:
For more information, see the Gradle documentation on the Java plugin here. The Android plugin uses a similar syntaxes, but because it uses its own sourceSets, this is done within the android object. Here’s an example, using the old project structure for the main code and remapping the androidTest sourceSet to the tests folder: android { resources.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] }
Note: because the old structure put all source files (java, aidl, renderscript, and java resources) in the same folder, we need to remap all those new components of the sourceSet to the same src folder.
Note: setRoot() moves the whole sourceSet (and its sub folders) to a new folder. This moves src/androidTest/* to tests/* This is Android specific and will not work on Java sourceSets. The ‘migrated’ sample shows this. Applying a plugin to the build file automatically creates a set of build tasks to run. Both the Java plugin and the Android plugin do this.
The convention for tasks is the following:
This allows you to always call the same task(s) no matter what the type of project is, or what plugins are applied. For instance, applying the findbugs plugin will create a new task and make check depend on it, making it be called whenever the check task is called. From the command line you can get the high level task running the following command: gradle tasks For a full list and seeing dependencies between the tasks run:
gradle tasks --all Note: Gradle automatically monitor the declared inputs and outputs of a task.
Running the build twice without change will make Gradle report all tasks as UP-TO-DATE, meaning no work was required. This allows tasks to properly depend on each other without requiring unneeded build operations. The Java plugin creates mainly two tasks, that are dependencies of the main anchor tasks:
The tests are compiled with testClasses, but it is rarely useful to call this as test depends on it (as well as classes). In general, you will probably only ever call assemble or check, and ignore the other tasks. You can see the full set of tasks and their descriptions for the Java plugin here. Android tasksThe Android plugin use the same convention to stay compatible with other plugins, and adds an additional anchor task:
The new anchor tasks are necessary in order to be able to run regular checks without needing a connected device.
Note that build does not depend on deviceCheck, or connectedCheck. An Android project has at least two outputs: a debug APK and a release APK. Each of these has its own anchor task to facilitate building them separately:
They both depend on other tasks that execute the multiple steps needed to build an APK. The assemble task depends on both, so calling it will build both APKs.
Tip: Gradle support camel case shortcuts for task names on the command line. For instance: gradle aR is the same as typing
gradle assembleRelease as long as no other task match ‘aR’
The check anchor tasks have their own dependencies:
Basic Build CustomizationThe Android plugin provides a broad DSL to customize most things directly from the build system.
Manifest entriesThrough the DSL it is possible to configure the following manifest entries:
buildToolsVersion "19.0.0"
versionName "2.0" minSdkVersion 16 The defaultConfig element inside the android element is where all this configuration is defined. Previous versions of the Android Plugin used packageName to configure the manifest 'packageName' attribute.
Starting in 0.11.0, you should use applicationId in the build.gradle to configure the manifest 'packageName' entry.
This was disambiguated to reduce confusion between the application's packageName (which is its ID) and
java packages.
The power of describing it in the build file is that it can be dynamic. For instance, one could be reading the version name from a file somewhere or using some custom logic:
Note: Do not use function names that could conflict with existing getters in the given scope. For instance instance defaultConfig { ...} calling getVersionName() will automatically use the getter of defaultConfig.getVersionName() instead of the custom method.
If a property is not set through the DSL, some default value will be used. Here’s a table of how this is processed.
The value of the 2nd column is important if you use custom logic in the build script that queries these properties. For instance, you could write:
If the value remains null, then it is replaced at build time by the actual default from column 3, but the DSL element does not contain this default value so you can't query against it.
This is to prevent parsing the manifest of the application unless it’s really needed. Build TypesBy default, the Android plugin automatically sets up the project to build both a debug and a release version of the application.
These differ mostly around the ability to debug the application on a secure (non dev) devices, and how the APK is signed.
The debug version is signed with a key/certificate that is created automatically with a known name/password (to prevent required prompt during the build). The release is not signed during the build, this needs to happen after. This configuration is done through an object called a BuildType. By default, 2 instances are created, a debug and a release one. The Android plugin allows customizing those two instances as well as creating other Build Types. This is done with the buildTypes DSL container:
The above snippet achieves the following:
The possible properties and their default values are:
In addition to these properties, Build Types can contribute to the build with code and resources. For each Build Type, a new matching sourceSet is created, with a default location of src/<buildtypename>/ This means the Build Type names cannot be main or androidTest (this is enforced by the plugin), and that they have to be unique to each other.
Like any other source sets, the location of the build type source set can be relocated:
Additionally, for each Build Type, a new assemble<BuildTypeName> task is created.
The assembleDebug and assembleRelease tasks have already been mentioned, and this is where they come from. When the debug andrelease Build Types are pre-created, their tasks are automatically created as well. The build.gradle snippet above would then also generate an assembleJnidebug task, and assemble would be made to depend on it the same way it depends on the assembleDebug and assembleRelease tasks. Tip: remember that you can type gradle aJ to run the assembleJnidebug task. Possible use case:
Signing ConfigurationsSigning an application requires the following:
By default, there is a debug configuration that is setup to use a debug keystore, with a known password and a default key with a known password. The debug keystore is located in $HOME/.android/debug.keystore, and is created if not present. The debug Build Type is set to use this debug SigningConfig automatically. It is possible to create other configurations or customize the default built-in one. This is done through the signingConfigs DSL container:
The above snippet changes the location of the debug keystore to be at the root of the project. This automatically impacts any Build Types that are set to using it, in this case the debug Build Type.
It also creates a new Signing Config and a new Build Type that uses the new configuration. Note: Only debug keystores located in the default location will be automatically created. Changing the location of the debug keystore will not create it on-demand. Creating a SigningConfig with a different name that uses the default debug keystore location will create it automatically. In other words, it’s tied to the location of the keystore, not the name of the configuration. Note: Location of keystores are usually relative to the root of the project, but could be absolute paths, thought it is not recommended (except for the debug one since it is automatically created). Note: If you are checking these files into version control, you may not want the password in the file. The following Stack Overflow post shows ways to read the values from the console, or from environment variables.
We'll update this guide with more detailed information later.
android {Running ProGuardProGuard is supported through the Gradle plugin for ProGuard version 4.10. The ProGuard plugin is applied automatically, and the tasks are created automatically if the Build Type is configured to run ProGuard through the minifyEnabled property.
buildTypes { release { minifyEnabled true proguardFile getDefaultProguardFile('proguard-android.txt') } } productFlavors {
flavor1 { }
flavor2 {
proguardFile 'some-other-rules.txt' }
}
Variants use all the rules files declared in their build type, and product flavors.
There are 2 default rules files
They are located in the SDK. Using getDefaultProguardFile() will return the full path to the files. They are identical except for enabling optimizations.
Shrinking ResourcesYou can also remove unused resources, automatically, at build time. For more information, see the Resource Shrinking document.
Gradle projects can have dependencies on other components. These components can be external binary packages, or other Gradle projects.
Dependencies on binary packagesLocal packagesTo configure a dependency on an external library jar, you need to add a dependency on the compile configuration.
Note: the dependencies DSL element is part of the standard Gradle API and does not belong inside the android element. The compile configuration is used to compile the main application. Everything in it is added to the compilation classpath and also packaged in the final APK. There are other possible configurations to add dependencies to:
Creating a new Build Type automatically creates a new configuration based on its name. This can be useful if the debug version needs to use a custom library (to report crashes for instance), while the release doesn’t, or if they rely on different versions of the same library. Remote artifactsGradle supports pulling artifacts from Maven and Ivy repositories.
First the repository must be added to the list, and then the dependency must be declared in a way that Maven or Ivy declare their artifacts.
Note: mavenCentral() is a shortcut to specifying the URL of the repository. Gradle supports both remote and local repositories. Note: Gradle will follow all dependencies transitively. This means that if a dependency has dependencies of its own, those are pulled in as well. For more information about setting up dependencies, read the Gradle user guide here, and DSL documentation here. Multi project setupGradle projects can also depend on other gradle projects by using a multi-project setup.
A multi-project setup usually works by having all the projects as sub folders of a given root project. For instance, given to following structure:
We can identify 3 projects. Gradle will reference them with the following name:
Each projects will have its own build.gradle declaring how it gets built. Additionally, there will be a file called settings.gradle at the root declaring the projects. This gives the following structure:
The content of settings.gradle is very simple: include ':app', ':libraries:lib1', ':libraries:lib2' This defines which folder is actually a Gradle project.
The :app project is likely to depend on the libraries, and this is done by declaring the following dependencies:
In the above multi-project setup, :libraries:lib1 and :libraries:lib2 can be Java projects, and the :app Android project will use their jar output.
However, if you want to share code that accesses Android APIs or uses Android-style resources, these libraries cannot be regular Java project, they have to be Android Library Projects. Creating a Library ProjectA Library project is very similar to a regular Android project with a few differences.
Since building libraries is different than building applications, a different plugin is used. Internally both plugins share most of the same code and they are both provided by the same com.android.tools.build.gradle jar.
This creates a library project that uses API 15 to compile. SourceSets, and dependencies are handled the same as they are in an application project and can be customized the same way.
Differences between a Project and a Library ProjectA Library project's main output is an .aar package (which stands for Android archive). It is a combination of compile code (as a jar file and/or native .so files) and resources (manifest, res, assets).
A library project can also generate a test apk to test the library independently from an application.
The same anchor tasks are used for this (assembleDebug, assembleRelease) so there’s no difference in commands to build such a project. For the rest, libraries behave the same as application projects. They have build types and product flavors, and can potentially generate more than one version of the aar.
Note that most of the configuration of the Build Type do not apply to library projects. However you can use the custom sourceSet to change the content of the library depending on whether it’s used by a project or being tested.
Referencing a LibraryReferencing a library is done the same way any other project is referenced:
Note: if you have more than one library, then the order will be important. This is similar to the old build system where the order of the dependencies in the project.properties file was important.
Library PublicationBy default a library only publishes its release variant. This variant will be used by all projects referencing the library, no matter which variant they build themselves. This is a temporary limitation due to Gradle limitations that we are working towards removing.
You can control which variant gets published with
Note that this publishing configuration name references the full variant name. Release and debug are only applicable when there are no flavors. If you wanted to change the default published variant while using flavors, you would write:
Publishing of all variants are not enabled by default. To enable them:
It is important to realize that publishing multiple variants means publishing multiple aar files, instead of a single aar containing multiple variants. Each aar packaging contains a single variant.
Publishing an variant means making this aar available as an output artifact of the Gradle project. This can then be used either when publishing to a maven repository, or when another project creates a dependency on the library project.
Gradle has a concept of default" artifact. This is the one that is used when writing:
compile project(':libraries:lib2') To create a dependency on another published artifact, you need to specify which one to use:
Important: When enabling publishing of non default, the Maven publishing plugin will publish these additional variants as extra packages (with classifier). This means that this is not really compatible with publishing to a maven repository. You should either publish a single variant to a repository OR enable all config publishing for inter-project dependencies.
Building a test application is integrated into the application project. There is no need for a separate test project anymore.
Unit TestingFor the experimental unit testing support added in 1.1, please see this page. The rest of this section describes "instrumentation tests" that can run on a real device (or an emulator) and require a separate, testing APK to be built.As mentioned previously, next to the main sourceSet is the androidTest sourceSet, located by default in src/androidTest/
From this sourceSet is built a test apk that can be deployed to a device to test the application using the Android testing framework. This can contain unit tests, instrumentation tests, and later uiautomator tests. The <instrumentation> node of the manifest for the test app is generated but you can create a src/androidTest/AndroidManifest.xml file to add other component to the test manifest.
There are a few values that can be configured for the test app, in order to configure the <instrumentation> node.
The value of the targetPackage attribute of the instrumentation node in the test application manifest is automatically filled with the package name of the tested app, even if it is customized through the defaultConfig and/or the Build Type objects. This is one of the reason this part of the manifest is generated automatically.
Additionally, the sourceSet can be configured to have its own dependencies. By default, the application and its own dependencies are added to the test app classpath, but this can be extended with
The test app is built by the task assembleTest. It is not a dependency of the main assemble task, and is instead called automatically when the tests are set to run.
Currently only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with:
Running testsAs mentioned previously, checks requiring a connected device are launched with the anchor task called connectedCheck.
This depends on the task androidTest and therefore will run it. This task does the following:
All test results are stored as XML files under build/androidTest-results (This is similar to regular jUnit results that are stored under build/test-results)
This can be configured with
The value of android.testOptions.resultsDir is evaluated with Project.file(String)
Testing Android LibrariesTesting Android Library project is done exactly the same way as application projects.
The only difference is that the whole library (and its dependencies) is automatically added as a Library dependency to the test app. The result is that the test APK includes not only its own code, but also the library itself and all its dependencies. The manifest of the Library is merged into the manifest of the test app (as is the case for any project referencing this Library). The androidTest task is changed to only install (and uninstall) the test APK (since there are no other APK to install.) Everything else is identical. When running unit tests, Gradle outputs an HTML report to easily look at the results.
The Android plugins build on this and extends the HTML report to aggregate the results from all connected devices. Single projectsThe project is automatically generated upon running the tests. Its default location is
build/reports/androidTests This is similar to the jUnit report location, which is build/reports/tests, or other reports usually located in build/reports/<plugin>/ The location can be customized with
In a multi project setup with application(s) and library(ies) projects, when running all tests at the same time, it might be useful to generate a single reports for all tests.
To do this, a different plugin is available in the same artifact. It can be applied with:
This should be applied to the root project, ie in build.gradle next to settings.gradle
Then from the root folder, the following command line will run all the tests and aggregate the reports: gradle deviceCheck mergeAndroidReports --continue Note: the --continue option ensure that all tests, from all sub-projects will be run even if one of them fails. Without it the first failing test will interrupt the run and not all projects may have their tests run. Lint supportAs of version 0.7.0, you can run lint for a specific variant, or for all variants, in which case it produces a report which describes which specific variants a given issue applies to.
You can configure lint by adding a lintOptions section like following. You typically only specify a few of these; this section shows all the available options.
android { lintOptions {
} Build VariantsOne goal of the new build system is to enable creating different versions of the same application.
There are two main use cases:
Product flavorsA product flavor defines a customized version of the application build by the project. A single project can have different flavors which change the generated application.
This new concept is designed to help when the differences are very minimum. If the answer to “Is this the same application?” is yes, then this is probably the way to go over Library Projects. Product flavors are declared using a productFlavors DSL container:
This creates two flavors, called flavor1 and flavor2.
Note: The name of the flavors cannot collide with existing Build Type names, or with the androidTest sourceSet. Build Type + Product Flavor = Build VariantAs we have seen before, each Build Type generates a new APK.
Product Flavors do the same: the output of the project becomes all possible combinations of Build Types and, if applicable, Product Flavors. Each (Build Type, Product Flavor) combination is called a Build Variant. For instance, with the default debug and release Build Types, the above example generates four Build Variants:
Product Flavor ConfigurationEach flavors is configured with a closure:
Note that the android.productFlavors.* objects are of type ProductFlavor which is the same type as the android.defaultConfig object. This means they share the same properties.
defaultConfig provides the base configuration for all flavors and each flavor can override any value. In the example above, the configurations end up being:
There are cases where a setting is settable on both the Build Type and the Product Flavor. In this case, it’s is on a case by case basis. For instance, signingConfig is one of these properties. This enables either having all release packages share the same SigningConfig, by setting android.buildTypes.release.signingConfig, or have each release package use their own SigningConfig by setting each android.productFlavors.*.signingConfig objects separately. Sourcesets and DependenciesSimilar to Build Types, Product Flavors also contribute code and resources through their own sourceSets.
The above example creates four sourceSets:
The following rules are used when dealing with all the sourcesets used to build a single APK:
Finally, like Build Types, Product Flavors can have their own dependencies. For instance, if the flavors are used to generate a ads-based app and a paid app, one of the flavors could have a dependency on an Ads SDK, while the other does not.
In this particular case, the file src/flavor1/AndroidManifest.xml would probably need to include the internet permission.
Additional sourcesets are also created for each variants:
These have higher priority than the build type sourcesets, and allow customization at the variant level.
Building and TasksWe previously saw that each Build Type creates its own assemble<name> task, but that Build Variants are a combination of Build Type and Product Flavor.
When Product Flavors are used, more assemble-type tasks are created. These are:
#2 allows building all APKs for a given Build Type. For instance assembleDebug will build both Flavor1Debug and Flavor2Debug variants. #3 allows building all APKs for a given flavor. For instance assembleFlavor1 will build both Flavor1Debug and Flavor1Release variants. The task assemble will build all possible variants. TestingTesting multi-flavors project is very similar to simpler projects.The androidTest sourceset is used for common tests across all flavors, while each flavor can also have its own tests. As mentioned above, sourceSets to test each flavor are created:
Similarly, those can have their own dependencies:
Running the tests can be done through the main deviceCheck anchor task, or the main androidTest tasks which acts as an anchor task when flavors are used.
Each flavor has its own task to run tests: androidTest<VariantName>. For instance:
The location of the test results and reports is as follows, first for the per flavor version, and then for the aggregated one:
Multi-flavor variantsIn some case, one may want to create several versions of the same apps based on more than one criteria.
For instance, multi-apk support in Google Play supports 4 different filters. Creating different APKs split on each filter requires being able to use more than one dimension of Product Flavors. Consider the example of a game that has a demo and a paid version and wants to use the ABI filter in the multi-apk support. With 3 ABIs and two versions of the application, 6 APKs needs to be generated (not counting the variants introduced by the different Build Types). However, the code of the paid version is the same for all three ABIs, so creating simply 6 flavors is not the way to go. Instead, there are two dimensions of flavors, and variants should automatically build all possible combinations. This feature is implemented using Flavor Dimensions. Flavors are assigned to a specific dimension
The android.flavorDimensions array defines the possible dimensions, as well as the order. Each defined Product Flavor is assigned to a dimension.
From the following dimensioned Product Flavors [freeapp, paidapp] and [x86, arm, mips] and the [debug, release] Build Types, the following build variants will be created:
Each variant is configured by several Product Flavor objects:
The flavor dimension is defined with higher priority first. So in this case: abi > version > defaultConfig Multi-flavors projects also have additional sourcesets, similar to the variant sourcesets but without the build type:
These allow customization at the flavor-combination level. They have higher priority than the basic flavor sourcesets, but lower priority than the build type sourcesets.
This affects all tasks using aapt.
preDexLibraries = false jumboMode = false javaMaxHeapSize "2048M"
Basic Java projects have a finite set of tasks that all work together to create an output.
The classes task is the one that compile the Java source code. It’s easy to access from build.gradle by simply using classes in a script. This is a shortcut for project.tasks.classes. In Android projects, this is a bit more complicated because there could be a large number of the same task and their name is generated based on theBuild Types and Product Flavors. In order to fix this, the android object has two properties:
Note that accessing any of these collections will trigger the creations of all the tasks. This means no (re)configuration should take place after accessing the collections. The DomainObjectCollection gives access to all the objects directly, or through filters which can be convenient.
All three variant classes share the following properties:
The ApplicationVariant class adds the following:
The LibraryVariant class adds the following:
The TestVariant class adds the following:
API for Android specific task types.
The API for each task type is limited due to both how Gradle works and how the Android plugin sets them up. First, Gradle is meant to have the tasks be only configured for input/output location and possible optional flags. So here, the tasks only define (some of) the inputs/outputs.
Second, the input for most of those tasks is non-trivial, often coming from mixing values from the sourceSets, the Build Types, and the Product Flavors. To keep build files simple to read and understand, the goal is to let developers modify the build by tweak these objects through the DSL, rather than diving deep in the inputs and options of the tasks and changing them.
Also note, that except for the ZipAlign task type, all other types require setting up private data to make them work. This means it’s not possible to manually create new tasks of these types.
This API is subject to change. In general the current API is around giving access to the outputs and inputs (when possible) of the tasks to add extra processing when required). Feedback is appreciated, especially around needs that may not have been foreseen. For Gradle tasks (DefaultTask, JavaCompile, Copy, Zip), refer to the Gradle documentation. BuildType and Product Flavor property referencecoming soon.
For Gradle tasks (DefaultTask, JavaCompile, Copy, Zip), refer to the Gradle documentation.
Using sourceCompatibility 1.7With Android KitKat (buildToolsVersion 19) you can use the diamond operator, multi-catch, strings in switches, try with resources, etc. To do this, add the following to your build file:
android { compileSdkVersion 19 buildToolsVersion "19.0.0" defaultConfig { minSdkVersion 7 targetSdkVersion 19 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } } Note that you can use
minSdkVersion with a value earlier than 19, for all language features except try with resources. If you want to use try with resources, you will need to also use a minSdkVersion of 19.You also need to make sure that Gradle is using version 1.7 or later of the JDK. (And version 0.6.1 or later of the Android Gradle plugin.)
|
相关推荐
Gradle是一款强大的构建自动化工具,尤其在Java、Android开发领域广泛应用。它采用了Groovy和Kotlin作为构建脚本语言,提供了灵活的构建配置和强大的插件系统,使得开发者能够高效地管理和构建项目。 标题提到的...
在Android Studio中,Gradle还负责处理Android应用程序的编译、打包、测试和发布等任务,是Android开发不可或缺的一部分。 总的来说,理解并正确使用Gradle离线包及其校验文件是提高开发效率和保证代码安全的重要一...
2. **lib** 目录:存放Gradle的核心库和各种插件,这些库文件使得Gradle能够执行构建过程中的编译、打包、测试等任务。 3. **docs** 目录(可能包含):提供Gradle的文档,包括API参考和用户指南,帮助开发者了解...
Gradle 是一个强大的构建自动化工具,广泛用于Java、Android和其他多语言项目。Gradle-8.0.1-all.zip是一个包含Gradle完整版本8.0.1的压缩包,为开发者提供了一站式解决方案,无需单独下载各种依赖。这个压缩包的...
"gradle-6.1.1-all.zip" 是Gradle 6.1.1版本的完整打包文件,其中包含了Gradle运行所需的所有组件,包括核心库、插件、文档等。这个版本的Gradle引入了一些新特性,优化了性能,并修复了一些已知问题。例如,它可能...
3. **文档和资源**: 可能包含Gradle的用户手册、开发者指南以及相关的API文档,这些对于学习和理解Gradle的工作原理非常有帮助。 下载Gradle-6.1.1-bin.zip并解压后,可以将Gradle的路径添加到系统的PATH环境变量中...
Android Gradle插件是Android开发中的重要组成部分,它与Android Studio紧密协作,负责构建、编译和打包Android应用。在给定的压缩包文件"android_gradle-5.6.4-all.rar"中,包含了Gradle 5.6.4版本的完整资源,这...
- **官方文档**:访问Gradle官方网站获取详细的用户指南和API文档,了解如何更好地使用Gradle。 - **社区支持**:Gradle有一个活跃的开发者社区,可以在论坛、Stack Overflow等平台寻求帮助和分享经验。 - **在线...
1. **基于任务的构建**:Gradle允许你定义一系列的任务,每个任务都有明确的目标,如编译代码、打包应用或执行测试。你可以根据需要运行这些任务,或者通过依赖关系让Gradle自动决定执行顺序。 2. **插件系统**:...
Gradle 是一个强大的构建自动化工具,广泛应用于Java、Android等项目的构建管理。...在使用过程中,如果遇到任何问题,开发者可以通过官方文档或社区资源寻找解决方案,以充分利用Gradle的强大功能。
Gradle 是一个强大的构建自动化工具,尤其在 Android 开发领域被广泛应用。它的主要任务是管理项目的依赖、构建过程以及打包应用程序。在这个特定的情景中,我们关注的是 Gradle 的一个特定版本——`gradle-8.0-bin`...
- `docs` 目录:可能包含了Gradle的文档,如用户手册和API参考。 - `licences` 目录:包含了所有使用的软件许可证信息。 要使用Gradle 6.7.1,你需要将其添加到系统的PATH环境变量中,或者创建一个软链接到`bin`...
2. **Android与Gradle**:在Android开发中,Gradle是默认的构建系统,它允许灵活地配置项目结构、依赖管理和打包选项。通过集成Android Studio,开发者可以轻松地管理Gradle构建脚本(build.gradle)和项目级配置...
在Android Studio中,Gradle是默认的构建系统,用于编译、打包和测试应用程序。 标题“gradle-5.5-all.zip”表明这是Gradle 5.5版本的完整发行包,包含了构建所需的所有组件。"all"这个后缀意味着这个zip文件包括了...
3. `docs`目录:可能包含用户指南、API文档等资源,帮助开发者理解和使用Gradle。 4. `LICENSE`和`NOTICE`文件:分别提供了软件许可协议和版权信息。 总的来说,Gradle-1.12-all.zip是一个适用于Android Studio开发...
在Android开发环境中,Gradle是必不可少的部分,它与Android Studio紧密集成,负责编译、打包和测试Android应用程序。这个离线包包含了Gradle的完整分布,包括Gradle二进制文件、库、插件和其他资源,确保开发者可以...
Gradle 是一个强大的自动化构建工具,广泛用于Java、Android和其他基于 JVM 的项目。"gradle-8.0-bin.zip" 文件是Gradle的二进制发行版,版本为8.0,通常包含了运行Gradle所需的可执行文件和库,但不包含源代码或...
3. 执行任务:在命令行中切换到项目根目录,输入“gradle tasks”列出所有可用的任务,然后通过“gradle [taskName]”执行特定任务,如“gradle build”来编译和打包项目。 4. 缓存管理:Gradle 6.8改进了缓存机制...
Gradle-4.10.1-all.zip是Gradle的特定版本打包文件,包含了运行和构建项目所需的全部组件。 这个版本(4.10.1)可能是一个稳定版,发布于某个时间点,为开发者提供了一个可靠的构建环境。Gradle的版本号通常由三...
3. **Android支持**:对于Android开发者而言,Gradle 6.5与Android Studio有良好的集成,支持最新的Android插件版本,提供了更好的兼容性和新特性,如Android应用模块打包的优化。 4. **插件系统**:Gradle的插件...