带有即时应用程序的 android 架构组件

标签 android module android-gradle-plugin android-instant-apps android-architecture-components

我想让我的应用程序为免安装应用程序做好准备。 我创建了一个应用程序模块、基本模块和一个功能模块。 如果我在此配置中运行我的项目,一切都会很好。

当我在我的基本模块 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'

一切都恢复正常了。

Official document reference

关于带有即时应用程序的 android 架构组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47198686/

相关文章:

android - 我正在尝试将 Android 旧库升级到 androidx (Android + Kotlin)

android - 如何在 android webview 中播放视频 URL

安卓 O : Notification Channel localization

java - 为什么客户端套接字可以检测到服务器套接字关闭,但反之则不行?

F#:模块 let 和类型 static let 之间有什么区别?

python - 如何安全使用exec?我想使用动态加载的代码模块作为配置文件

multithreading - 另一个 "Can' t 在未调用 Looper.prepare() 的线程内创建处理程序”主题

module - 如何从父文件夹模块或兄弟文件夹模块访问模块?

java - 生成签名的 APK 输出没有文件

android - 如何安装存储库 com.android.support :appcompat-v7