- Mastering Android Development with Kotlin
- Milo? Vasi?
- 323字
- 2021-07-02 15:20:56
Using the Gradle build tool
During our development, we will need to build different build variants or run tests. Those tests can be executed for only certain build variants, if needed, or for all of them.
In the following examples, we will cover some of the most common Gradle use cases. We will start with cleaning and building.
As you remember, the Journaler application has the following build types defined:
- debug
- release
- staging
- preproduction
The following build flavors are also defined in the Journaler application:
- demo
- complete
- special
Open terminal. To remove everything we built so far, and all temporally build derivates, execute the following command line:
./gradlew clean
It takes some time to do the cleaning. Then execute the following command line:
./gradlew assemble.
This assembles everything--all the build variants that we have in our application. Imagine the time impact it can have if we are dealing with a really big project. Therefore, we will isolate the build command. To build only the debug build type, execute the following command line:
./gradlew assembleDebug
It will be executed much faster than the previous example! This builds all flavors for the debug build type. In order to be more effective, we will instruct Gradle that we are interested only in a complete build flavor for the debug build type. Execute this:
./gradlew assembleCompleteDebug
This executes much faster. Here, we will mention several more important Gradle commands that are useful:
To run all unit tests execute:
./gradlew test
In case you want to run unit tests for a specific build variant, execute this command:
./gradlew testCompleteDebug
In Android, we can run tests on a real device instance or an emulator. Usually, those tests have access to some of Android's components. To execute those (instrumentation) tests, you can use the command shown in the following example:
./gradlew connectedCompleteDebug
You will find more about tests and testing Android applications in the final chapters of this book.
- Learning Cython Programming
- Boost C++ Application Development Cookbook(Second Edition)
- Instant QlikView 11 Application Development
- Silverlight魔幻銀燈
- Python貝葉斯分析(第2版)
- INSTANT Django 1.5 Application Development Starter
- Mastering Android Game Development
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- 嵌入式Linux C語言程序設計基礎教程
- Practical Predictive Analytics
- Puppet:Mastering Infrastructure Automation
- Swift High Performance
- Java程序性能優化實戰
- 趣學Python游戲編程
- KnockoutJS Essentials