In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces what is the implementation process of gradle in the Android project, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Gradle file execution process
Students who have done Android development know that there are three gradle files in the Android project, do you know their implementation process? Please look at the picture below:
In order to verify the conclusion
We use the output string to verify the correctness of
The output is as follows:
Customizing the import method of gradle files
The three gradle files described above are managed by the system, can we create gradle files? The answer is yes.
So how do we introduce the gradle file we created? For more information, please see the following picture:
Step 1: create a yiqi.gradle file
Ext {/ / ext cannot drop / / define a string firstName = "yiqi" / / define a collection firstList = ['asides,' b'] / / define a map firstMap = ['K1FY:' v1century, 'K2FY:' v2']}
Step 2: introduce a custom yiqi.gradle file into the build.gradle file under project
Step 3: use variables
Note: ext {} cannot be reduced in custom gradle files.
How variables defined in gradle are used by java code
Step 1: define a variable in gradle
/ / define a string firstName = "yiqi" / / define a collection firstList = ['astats,' b'] / / define a map firstMap = [K1: 'v1lines,' K2codes: 'v2'] / / define an integer firstInt = 10 / / define a bool firstBool = false / / define a double firstDouble = 10.25
Step 2: configure the configuration code that automatically generates java code = "mainly use buildConfigField code."
Note: the three parameters in the buildConfigField () method are all of string type, otherwise an error will be reported
Step 3: click clean Project and then click make Project
We can see our configuration information in BuildConfig, an automatically built class, and these fields can be used in formal code.
Thank you for reading this article carefully. I hope the article "what is the implementation process of gradle in the Android project" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.