butterknife:10.1.0版本在引入运行项目时,出现了这个错误(sdk版本28)
Manifest merger failed : 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 <application> element at AndroidManifest.xml:5:5-19:19 to override.
这是什么鬼?
于是我上网查一下,网上解释说
我原工程中和导入的工程中的AndroidManifest.xml文件中都使用了app name,合并manifest的过程出现了问题。
解决的方法为:在原工程的AndroidManifest.xml的文件中加上
<application
tools:replace="android:appComponentFactory" //除了这行之外
android:appComponentFactory="任意字符" //还要加上这一行
好吧 ,我试了一下,天哪又出现了这个错误
Error: Static interface methods are only supported starting with Android N (--min-api 24): void butterknife.Unbinder.lambda$static$0()
搞什么,这是为什么,于是乎,我深呼一口气,再查
网上给了我这么一个解释:
错误原因:这是因为java8才支持静态接口方法的原因
解决办法:可以通过在app的build.gradle文件中配置使用java8编译:
好啊,让加就加吧
有两种方式:
1.自动添加:file-->project structure -->app
2.手动添加:如图↓
哎呀,怎么又错了,为啥又报这么一个错呢?!
Error: Program type already present: androidx.versionedparcelable.ParcelImpl$1
再查!
哦~
原来 我用的依赖库文件用了androidx 这个支持库
那咱引入一下呗
implementation 'androidx.appcompat:appcompat:1.0.0'
引入之后,出现这个错误!!!!
Error: Program type already present: android.support.v4.app.INotificationSideChannel$Stub
好吧是我忘记一个地方:
在gradle.properties中添加代码
android.useAndroidX=true
android.enableJetifier=true
最后将引用v7包的地方都换成androidx,别忘了布局 大功告成!!!!
来一张不算优雅的helloword