Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jiang111 authored Jul 22, 2019
1 parent 1707c9d commit d2c01e9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,34 @@ Android{
* 不要滥用<item name="android:windowIsTranslucent">true</item> 属性,切勿为app设置该属性,而仅针对具体的activity进行设置.公司有位开发为整个app设置了该属性,我们有个签名的横屏页面,其他是强制竖屏页面,有个需求是进入该竖屏页面后某些特殊原因需要自动跳转到签名页面,而跳转到横屏页面后导致整个app的所有页面生命周期全部重新走了一遍,该签名页面无限循环打开.


* 当你在多module中使用了多个三方库,而这些三方库使用了多个版本的Recyclerview,我们可以通过exclude group: 'com.android.support', module: 'recyclerview-v7' 来实现使用项目中的版本,但是这样造成的问题是每添加一个库就得写一下exclude,这样很不友好,而gradle为我们提供了依赖替换规则.
如下代码实现了全局替换recyclerview的版本
```
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (requested.name.startsWith("recyclerview-v7")) {
details.useVersion "28.0.0"
}
}
}
}
```
当然,依赖替换规则还允许我们在本地库和远程库之间进行切换.
```
configurations.all {
resolutionStrategy.dependencySubstitution {
if (useLocal) { //如果使用本地仓库,系统将会把org.utils:api依赖替换为本地api的project
substitute module("org.utils:api") because "we work with the unreleased development version" with project(":api")
}
}
}
```



#### 摘自[如下地址](https://github.com/jiang111/awesome-android-tips/blob/master/Authors.md)


Expand Down

0 comments on commit d2c01e9

Please sign in to comment.