- 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.
- LabVIEW程序設計基礎與應用
- Delphi程序設計基礎:教程、實驗、習題
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- Rust實戰
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- Twilio Best Practices
- C語言最佳實踐
- Oracle 18c 必須掌握的新特性:管理與實戰
- Visual FoxPro程序設計習題集及實驗指導(第四版)
- Mastering Android Game Development
- Java零基礎實戰
- Web前端應用開發技術
- Azure Serverless Computing Cookbook
- Python 3 數據分析與機器學習實戰
- C#程序設計基礎入門教程