Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Android gradle configure decimation merge

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you how to configure Android gradle to extract and merge the relevant knowledge points, the content is detailed, the logic is clear, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.

First, why merge

When there are too many model or library in the project, such as using componentization or introducing third-party libraries, you need to configure multiple build gradle files, and once you need to unify its SDK or other component versions, you need to modify multiple files at the same time, which is really troublesome, so it is very necessary to extract gradle configuration. If you want to modify the version after extraction, you only need to modify the public file.

Second, how to operate the file

1. Create a new gradle folder

1. Function: store extracted public gradle files

two。 Operation steps

Create a new gradle folder (Directory) in the project home directory

Create a new androi.gradle file under the gradle folder

Copy all the content in app.gradle and modify it based on it

First modify the file type declaration on the first line

Originally: apply from: 'com.android.application'

Modified to: project.plugins.apply ("com.android.application")

Now introduce it into app.gradle or other model (the same is true for library, but the file type is different and you don't need applicationID). The build reference is successful.

Apply from:'.. / gradle/android.gradle'

two。 Create a new config folder

1. Function: to store public configuration files such as sdk version numbers

two。 Operation steps

Create a new config folder in the project home directory

Then create the subfile config.gradle (of course, you can also put it under the gradle folder)

Introduce under project

Apply from:'/ config/config.gradle'

Write the configuration content, taking model as an example:

Ext {androidVersion = [minSdkVersion: 23, targetSdkVersion: 29, versionCode: 1, versionName: '1.0.0, compileSdkVersion: 29, buildToolsVersion:' 29.0.2, applicationId: 'com.xxx.plugin_package']}

5. Defined in android.gradle

Def config = rootProject.ext.androidVersion

6. Use in android.gradle

These are all the contents of the article "how to configure Android gradle to extract and merge". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report