Android依赖笔记
source link: https://aprildown.xyz/2022/06/02/android-library-dependency/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Android依赖笔记
2022-06-02Android
整理自The definitive guide to Android library development by Jeroen Mols, Plaid EN
相比JAR(代码压缩包?),AAR还有Resources和Manifest,但二者都没有签名且不包括依赖。它们各自所需的依赖定义于pom文件中。
如果所需的依赖是本地文件,则需要方法来绕过限制:
- 把依赖发布到Maven
- FAR AAR插件
- 把依赖内容复制到Library中
限制多个依赖间的内部类
package com.example.internal.database
- 混淆为
package com.example.internal.a
- 把依赖内容复制到Library中
Transitive Dependency及在pom文件中定义的依赖
Grdle会默认选择所有版本最高的依赖。调整方法有
忽略依赖的Transitive Dependency
implementation ('com.example:library:1.0.0') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}全局指定依赖版本
configurations.all {
resolutionStrategy {
force 'com.squareup.okhttp3:okhttp:3.12.0'
}
}
这些方法可能会造成编译或运行时失败,尽量避免它们。
开发Library时,使用稳定版本(几个月到一两年)的依赖,最好不要更新。
在
res/values/public.xml
声明后,只是Android Studio不再自动补全了。android {
resourcePrefix 'mylib_'
}来限定名称空间。不过只是让Android Studio警告一下。
设置为必须声明Class Visibility
android {
kotlinOptions {
freeCompilerArgs += '-Xexplicit-api=strict'
}
}
Recommend
-
150
在我们开发安卓项目的时候,不会所有的功能都自己去造轮子,经常要使用到各种的其他包,其中有谷歌给我们提供的各种support包,也有各种第三方的功能库,有时候我们自己也会将一些功能封装成包。这些包存在和导入的形式也多种多样,有远程仓库的,有直接拷贝到本地...
-
60
-
2
如果想学点什么,就别依赖笔记软件 2018-01-01 笔记软件会造成一种错觉:已经记录下来的就是我的了,不管对这些记录的东西了解如何。尤其一些笔记软件有强大的搜索功能,甚至能搜索图片里的文字,会更加重这种感觉。而学习的重...
-
13
【Gradle】Android Studio中Gradle重复依赖的问题 问题项目中有个Module需要解析json所以选用了依赖Gson,但是编译时报错如下: Error:Execution failed for task ':a...
-
8
Android Studio中的6种依赖 Compile compile是对所有的build type以及favlors都会参与编译并且打包到最终的apk文件中。
-
7
Android 5.0 进程A和APK B依赖关系问题的研究
-
6
最近在折腾一个项目,对Ruby/Nodejs的版本有要求 ruby –version // ruby 2.2.3 node –version // v0.12.4 npm –version // 2.10.1 Ubuntu14.04 采用RVM来...
-
3
WordPress Hosting...
-
8
【笔记】Pip下载离线依赖包 2022-11-26 Pip下载离线依赖包对应平台对应Python版本的离线依赖包只能安装在对应平台的对应Python版本下 <pkg...
-
2
【笔记】Python3 项目依赖的导入导出 牵丝戏 - 银临 & Aki 阿杰 嘲笑谁恃美扬威 没了心如何相配 盘铃声清脆 帷...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK