android architecture components with instant app

倖福魔咒の 提交于 2019-12-10 11:05:28

问题


I want to make my app ready for instant apps. I have created an app module, base module and a feature module. if I run my project in this configuration everything works great.

when i implement the following lines inside my base module Gradle file.

annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
api "android.arch.lifecycle:extensions:1.0.0"

the Gradle build succeeds but I lose my default activity and can't run the project. the default activity is inside my base module manifest.

if i change the extensions line with implementation.

implementation "android.arch.lifecycle:extensions:1.0.0"

the following error happens:

Error:Execution failed for task ':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

does anyone knows what the problem can be?


回答1:


When using the support lib 26.1.0 or higher the lifecycle functionality is included inside. by removing the following lib lines

annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
api "android.arch.lifecycle:extensions:1.0.0"

and only using the :

 implementation 'com.android.support:appcompat-v7:26.1.0'

everything was working again.

Official document reference



来源:https://stackoverflow.com/questions/47198686/android-architecture-components-with-instant-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!