当前位置:网站首页>[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 》






边栏推荐
- Basic concept and implementation of overcoming hash
- 【FH-GFSK】FH-GFSK信号分析与盲解调研究
- [FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
- [shutter] animation animation (shutter animation type | the core class of shutter animation)
- Niu Ke swipes questions and clocks in
- 正确甄别API、REST API、RESTful API和Web Service之间的异同
- excel去除小数点后面的数据,将数字取整
- 电话网络问题
- 如今少年已归来,人间烟火气最抚凡人心 复工了~
- 1038 Recover the Smallest Number
猜你喜欢

Leetcode 6103 - minimum fraction to delete an edge from the tree

异步、郵件、定時三大任務
![[shutter] image component (configure local GIF image resources | load placeholder with local resources)](/img/73/19e2e0fc5ea6f05e34584ba40a452d.jpg)
[shutter] image component (configure local GIF image resources | load placeholder with local resources)

1696C. Fishingprince Plays With Array【思维题 + 中间状态 + 优化存储】

(C language) data storage

FPGA - 7系列 FPGA内部结构之Clocking -04- 多区域时钟

安全运营四要素之资产、脆弱性、威胁和事件

leetcode 6103 — 从树中删除边的最小分数

异步、邮件、定时三大任务

Linear programming of mathematical modeling (including Matlab code)
随机推荐
【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
强化学习 Q-learning 实例详解
Niu Ke swipes questions and clocks in
matlab 多普勒效应产生振动信号和处理
[shutter] image component (configure local GIF image resources | load placeholder with local resources)
鏈錶內指定區間反轉
Infrared thermography temperature detection system based on arm rk3568
基本远程连接工具Xshell
Embrace the safety concept of platform delivery
kivy教程之在 Kivy App 中使用 matplotlib 的示例
Draw love with go+ to express love to her beloved
excel去除小数点后面的数据,将数字取整
R language generalized linear model function GLM, (model fit and expression diagnostics), model adequacy evaluation method, use plot function and car package function
2022.2.14 resumption
MySQL --- 数据库查询 - 条件查询
matlab查找某一行或者某一列在矩阵中的位置
Foundations of data science is free to download
用Go+绘制爱心给心爱的她表白
Explain the basic concepts and five attributes of RDD in detail
Detailed explanation of Q-learning examples of reinforcement learning