Androistudio lint检查去除无效代码

lint去除无效资源和代码

如何检测哪些图片未被使用

点击菜单栏 Analyze -> Run Inspection by Name -> unused resources -> Moudule
‘app’ -> OK,这样会搜出来哪些未被使用到未使用到xml和图片,如下:

如何检测哪些无效代码

使用Android Studio的Lint,步骤:点击菜单栏 Analyze -> Run Inspection by Name ->
unused declaration -> Moudule ‘app’ -> OK

去除重复依赖库优化

注意要点:其中app就是项目mudule名字。 正常情况下就是app!

gradlew app:dependencies

复制代码
关于依赖关系树的结构图如下所示,此处省略很多代码| | | | | | —

android.arch.core:common:1.1.1 (*)
|    |    |    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    +--- com.journeyapps:zxing-android-embedded:3.6.0
|    |    +--- com.google.zxing:core:3.3.2
|    |    \--- com.android.support:support-v4:25.3.1
|    |         +--- com.android.support:support-compat:25.3.1 -> 28.0.0 (*)
|    |         +--- com.android.support:support-media-compat:25.3.1
|    |         |    +--- com.android.support:support-annotations:25.3.1 -> 28.0.0
|    |         |    \--- com.android.support:support-compat:25.3.1 -> 28.0.0 (*)
|    |         +--- com.android.support:support-core-utils:25.3.1 -> 28.0.0 (*)
|    |         +--- com.android.support:support-core-ui:25.3.1 -> 28.0.0 (*)
|    |         \--- com.android.support:support-fragment:25.3.1 -> 28.0.0 (*)
\--- com.android.support:multidex:1.0.2 -> 1.0.3

复制代码
然后查看哪些重复jar

然后修改gradle配置代码api (rootProject.ext.dependencies["zxing"]){
    exclude module: 'support-v4'
    exclude module: 'appcompat-v7'
}

猜你喜欢

转载自blog.csdn.net/weixin_41620505/article/details/92639393
今日推荐