Search code examples
androidmoduleandroid-gradle-pluginandroid-instant-appsandroid-architecture-components

android architecture components with instant app


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?


Solution

  • 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