当前位置:网站首页>[androd] module dependency replacement of gradle's usage skills
[androd] module dependency replacement of gradle's usage skills
2022-07-03 01:19:00 【Xiao Chen knocked the code randomly】
background
We are in the process of multi module project development , There are scenes like this , The project relies on one's own or other colleagues aar modular , Sometimes for the convenience of development and debugging , Often put aar Change to local source code dependency , When the development is completed and submitted , It will be modified back to aar rely on , This will be very inconvenient , The development process is shown below :

solve
At first we passed in app Of build.gradle Inside dependency Judge if it needs local dependency aar, Just replace it with implementation project rely on , The pseudocode is as follows :
dependencies {
if(enableLocalModule) {
implementation 'custom:test:0.0.1'
} else {
implementation project(path: ':test')
}
}
This way, you don't have to modify the code back every time you submit it aar rely on , But if other modules also rely on this aar modular , There will be problems , Although you can continue to modify the dependencies in other modules , But it's invasive , And it can't completely solve the problem , Local dependencies and aar Dependent code inconsistencies .
Gradle Officials offer a better solution to this scenario DependencySubstitution, Use as follows :
step 1: stay settting.gradle, Add the following code :
// Load local module
if (file("local.properties").exists()) {
def properties = new Properties()
def inputStream = file("local.properties").newDataInputStream()
properties.load( inputStream )
def moduleName = properties.getProperty("moduleName")
def modulePath = properties.getProperty("modulePath")
if (moduleName != null && modulePath != null) {
include moduleName
project(moduleName).projectDir = file(modulePath)
}
}
step 2: stay app Of build.gradle Add the following code
configurations.all {
resolutionStrategy.dependencySubstitution.all { DependencySubstitution dependency ->
// use local module
if (dependency.requested instanceof ModuleComponentSelector && dependency.requested.group == "custom") {
def targetProject = findProject(":test")
if (targetProject != null) {
dependency.useTarget targetProject
}
}
}
}
step 3:: stay local.properties in
moduleName=:test
modulePath=../AndroidStudioProjects/TestProject/testModule
It's done here , The follow-up only needs to be in local.properties Opening and closing , That is to say aar Module local dependency debugging , You don't have to modify the code manually aar rely on .
Last
Give you a complete set of Android Study materials .
I used to find it on the Internet , The things found are scattered , Most of the time, I just look at it and it's gone , Time is wasted , The problem has not been solved yet , It's crazy .
Then I sorted out a set of materials myself , Also don't say , It's delicious !
The information is organized , There is a system , It's also comprehensive , It's not convenient for me to release it directly , You can first see if there is anything you can use .
** Attach white whoring address :《Android Architecture video +BATJ Interview topics PDF+ Learning notes 》






边栏推荐
- leetcode 6103 — 从树中删除边的最小分数
- [fh-gfsk] fh-gfsk signal analysis and blind demodulation research
- Excel removes the data after the decimal point and rounds the number
- 【C语言】分支和循环语句(上)
- 2022 coal mine gas drainage examination question bank and coal mine gas drainage examination questions and analysis
- R language ggplot2 visualization: use ggplot2 to display dataframe data that are all classified variables in the form of thermal diagram, and customize the legend color legend of factor
- 465. DFS backtracking of optimal bill balance
- Database SQL language 01 where condition
- [self management] time, energy and habit management
- 拥抱平台化交付的安全理念
猜你喜欢

FPGA - 7 Series FPGA internal structure clocking -04- multi area clock

Merge K sorted linked lists

Excel if formula determines whether the two columns are the same

MySQL基础用法02

Matlab Doppler effect produces vibration signal and processing

FPGA - 7系列 FPGA内部结构之Clocking -04- 多区域时钟
![[untitled]](/img/fd/f6b90536f10325a6fdeb68dc49c72d.png)
[untitled]
![[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core](/img/fb/c371ffaa9614c6f2fd581ba89eb2ab.png)
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core

Top ten regular spot trading platforms 2022

JDBC courses
随机推荐
Trois tâches principales: asynchrone, courrier et timing
删除有序链表中重复的元素-II
拥抱平台化交付的安全理念
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
2022 cable crane driver examination registration and cable crane driver certificate examination
Specified interval inversion in the linked list
Telephone network problems
JDBC courses
看疫情之下服装企业如何顺势而为
Niu Ke swipes questions and clocks in
链表内指定区间反转
Basic use of sringcloud & use of component Nacos
Mongodb common commands of mongodb series
[untitled]
Compare version number
1696C. Fishingprince Plays With Array【思维题 + 中间状态 + 优化存储】
[C language] branch and loop statements (Part 1)
18_ The wechat video number of wechat applet scrolls and automatically plays the video effect to achieve 2.0
Embrace the safety concept of platform delivery
Basis of information entropy