今天写了一个小demo,新建项目然后引入butterknife依赖的时候,一直编译不过,报错如下:
Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:5:5-19:19 to override.
经过各种折腾,终于get到,Androidx和Android support库不能共存。
查看那些库依赖了Androidx,
执行方法:Gradle-->工程名-->app-->help-->dependencies, 双击后打开build信息
找到了问题,果断回退依赖库的版本到8.8.0。
clean,然后重新编译。工程编译正常。
PS:
依赖库的时候,尽量不要使用latest.release
,而使用具体的版本。
1、不会因为依赖库更新,引起兼容问题;
2、减少每次去查找最新版本,可以节省编译时间。
参考文章: https://www.jianshu.com/p/f7a7a8765294?tdsourcetag=s_pctim_aiomsg