studio升级api28和butternife不兼容问题

前言

这几天项目不是很紧张,于是把studio和gradle都升级了下。目前我studio已经升级到 Androidstudio 3.3, 对应的gradle版本也升级到gradle-4.10.1-all,然后之前用的 butternife 是 8.5.1 版的,在升级studio以后就出现问题了,今天就这个问题做个记录。

  1. butternife在gitHub上的位置
  2. 问题描述
  3. 问题解决流程
  4. 最后得出结论
  5. 最终解决方案
    注:“问题解决流程”只做试错参考,时间足的话可以看看,具体解决问题在 “最后得出结论” 和 “最终解决方案”,时间紧迫的话只看2,4,5项就行。
butternife在gitHub上的位置

butternife源码 这里可以看到butternife最新更新,此做记录。

问题描述

首先说下我的情况,由于我的项目中建了一个 module依赖,项目结构如下:


6127340-b2634afcf3a8e128.png
image.png

其中,app_module是我的主module,lib是我自建的一个module。由于我studio升级到了3.3出现的不兼容,如果我lib中不引用 butternife的话,直接在主module(即app_module)对应的buildle.gradle中引用最新的butternife 10.0.0版本是可以用的,但是我需要字自建的lib_module中也引用butternife,于是运行的时候就出问题了。下面对此流程中出的问题一 一记录。

问题解决流程

此时我studio3.3,gradle为 gradle-4.10.1-all,sdk版本为28,引用butternife版本为 8.5.1,运行出现:

* What went wrong:
The Android Gradle plugin supports only Butterknife Gradle plugin version 9.0.0-rc2 and higher.
The following dependencies do not satisfy the required version:
root project 'demoUtil' -> com.jakewharton:butterknife-gradle-plugin:8.5.1

提示:butternife 需要版本在 9.0.0-rc2 或者以上,
于是我去了 butternife 的github处寻找答案,最后看到最新版本为 10.0.0,ok,于是我将app_module和lib_module的引用全部改为10.0.0(具体配置可以直接在butternife源码上看),运行后出现:

> Task :app:processDebugManifest FAILED
C:\work_space_demo\demoUtil\app\src\main\AndroidManifest.xml:22:18-91 Error:
    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:9:5-23:19 to override.

猜你喜欢

转载自blog.csdn.net/weixin_33928137/article/details/86860410