Focus-android: When converting this project as a library, facing 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.

Created on 31 Oct 2017  Â·  8Comments  Â·  Source: mozilla-mobile/focus-android

Hi,

I tried to convert the project into a library and integrate with a sample app. However, it is showing the error:

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.

Android Studio Version - 3.0 Stable

Top Level build.gradle
`// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
classpath 'org.ajoberstar:grgit:1.5.0'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.google.com' }
mavenCentral()
}

}

task clean(type: Delete) {
delete rootProject.buildDir
}

ext {
buildToolsVersion = '26.0.2'
compileSdkVersion = 26
minSdkVersion = 21
targetSdkVersion = 26
supportLibraryVersion = '26.1.0'
junitVersion = '4.12'
runnerVersion = '1.0.0'
espressoVersion = '3.0.0'
gsonVersion = '2.8.1'
archComp='1.0.0-rc1'
}`

Browser level module build.gradle
dependencies {
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:customtabs:$rootProject.supportLibraryVersion"
compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "android.arch.lifecycle:extensions:$rootProject.archComp"
compile('com.google.code.findbugs:annotations:3.0.1') {
// We really only need the SuppressFBWarnings annotation, everything else can be ignored.
// Without this we get weird failures due to dependencies.
transitive = false
}
compile 'org.mozilla.telemetry:telemetry:1.1.1'
// compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
compile 'com.adjust.sdk:adjust-android:4.11.4'
compile 'com.google.android.gms:play-services-analytics:10.2.6'
// Required by Adjust
// geckoCompile(name: 'geckoview-latest', ext: 'aar')
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.4.2'
testCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
androidTestCompile "com.android.support.test.espresso:espresso-core:$rootProject.espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile "com.android.support.test.espresso:espresso-idling-resource:$rootProject.espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-web:$rootProject.espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.7.0'
androidTestCompile "tools.fastlane:screengrab:1.1.0", {
exclude group: 'com.android.support', module: 'support-annotations'
}
}

P5

Most helpful comment

This exactly happened to me when I had one main project without implementation "android.arch.lifecycle:extensions:1.0.0" mentioned in dependencies but I included a library that had implementation "android.arch.lifecycle:extensions:1.0.0" in dependencies. Solution was to add implementation "android.arch.lifecycle:extensions:1.0.0" to the main project

All 8 comments

We currently bind the runtime and the compiler to the same version (in build.gradle):

    compile "android.arch.lifecycle:runtime:$architecture_components_version"
    compile "android.arch.lifecycle:extensions:$architecture_components_version"
    kapt "android.arch.lifecycle:compiler:$architecture_components_version"

It sounds like you may be doing one of:

  • Using an old version
  • Introducing a new version as part of the library conversion

I don't think there is anything actionable on our end – please feel free to reopen if you feel this is incorrect.

Hey @mcomella , thanks for responding.

But I've used the same version as mentioned in https://github.com/mozilla-mobile/focus-android/blob/master/build.gradle#L5
The difference is just that, the code is written in buildscript{} whereas, I've written it outside the buildscript in ext{} .

I tried to remove kapt version also but it didn't help.

Moreover, when I integrated it using the stable version 2.2(link), it worked.

What are the dependencies of your app module, this one is missing, I think? Is it still possible to run "./gradlew androidDependencies" and see what is causing the conflict?

I do not see the "runtime" dependency in your code at all. Did you remove it?

Looking at the docs it seems to be safe to use runtime:1.3 everywhere, or just the new "extensions" dependency - We might want to update our build scripts here too:
https://developer.android.com/topic/libraries/architecture/adding-components.html

This exactly happened to me when I had one main project without implementation "android.arch.lifecycle:extensions:1.0.0" mentioned in dependencies but I included a library that had implementation "android.arch.lifecycle:extensions:1.0.0" in dependencies. Solution was to add implementation "android.arch.lifecycle:extensions:1.0.0" to the main project

@semanticer you are right, thank you for your help.

@semanticer Your solution worked. Thanks. But what is the cause of the conflict? I am curious to understand how your solution works. Why should we add a dependency to the main project if that doesn't directly require it (I am talking about android.arch.lifecycle:extensions)? I am not using any Architecture Components in my app module. I am using it only in my library module.

@semanticer @thsaravana same thing was in my case i have added in my module only , Problem resolved by adding the same lifecycle dependency in my main project as well. Thanks guys.

As @semanticer mentions: "Solution was to add implementation "android.arch.lifecycle:extensions:1.0.0" to the main project",how can I do?

Was this page helpful?
0 / 5 - 0 ratings