我想让我的应用程序为免安装应用程序做好准备。 我创建了一个应用程序模块、基本模块和一个功能模块。 如果我在此配置中运行我的项目,一切都会很好。
当我在我的基本模块 Gradle 文件中实现以下行时。
annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
api "android.arch.lifecycle:extensions:1.0.0"
Gradle 构建成功,但我失去了我的默认 Activity ,无法运行该项目。默认 Activity 在我的基本模块 list 中。
如果我通过实现更改扩展行。
implementation "android.arch.lifecycle:extensions:1.0.0"
出现以下错误:
错误:任务 ':app:preDebugBuild' 执行失败。
Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.0.3) classpath. You should manually set the same version via DependencyResolution
有人知道问题出在哪里吗?
最佳答案
当使用支持库 26.1.0 或更高版本时,生命周期功能包含在其中。通过删除以下 lib 行
annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
api "android.arch.lifecycle:extensions:1.0.0"
并且只使用 :
implementation 'com.android.support:appcompat-v7:26.1.0'
一切都恢复正常了。
关于带有即时应用程序的 android 架构组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47198686/