AdevintaSpain / Barista

:coffee: The one who serves a great Espresso
Other
1.7k stars 120 forks source link

Failed to resolve: androidx.test:core:1.5.0 #466

Open cdiazc opened 1 year ago

cdiazc commented 1 year ago

Library Version:

4.3.0

Describe the Bug:

Failed to resolve dependencies when trying to use Barista with test:*:1.5.0.

This is the message output:

Unresolved dependencies

Cannot find a version of 'androidx.test:core' that satisfies the version constraints:
   Dependency path 'Flat:app:unspecified' --> 'androidx.test:core:1.5.0'
   Constraint path 'Flat:app:unspecified' --> 'androidx.test:core:{strictly 1.4.0}' because of the following reason: productionDebugRuntimeClasspath uses version 1.4.0
   Dependency path 'Flat:app:unspecified' --> 'androidx.test.ext:truth:1.5.0' (runtime) --> 'androidx.test:core:1.5.0'
   Dependency path 'Flat:app:unspecified' --> 'androidx.test.ext:junit-ktx:1.1.4' (runtime) --> 'androidx.test.ext:junit:1.1.4' (runtime) --> 'androidx.test:core:1.5.0'
   Dependency path 'Flat:app:unspecified' --> 'androidx.test.espresso:espresso-contrib:3.5.0' (runtime) --> 'androidx.test.espresso:espresso-core:3.5.0' (runtime) --> 'androidx.test:core:1.5.0'
   Dependency path 'Flat:app:unspecified' --> 'com.adevinta.android:barista:4.3.0' (releaseRuntimePublication) --> 'androidx.test.espresso:espresso-intents:3.4.0' (runtime) --> 'androidx.test:core:1.4.0'

Steps to reproduce the bug: Have a build.gradle file with:

        testImplementation        'androidx.test:core:1.5.0'
        androidTestImplementation 'androidx.test:core:1.5.0' 
        testImplementation        'androidx.test:rules:1.5.0'
        androidTestImplementation 'androidx.test:rules:1.5.0' 
        testImplementation        'androidx.test.ext:truth:1.5.0' 
        androidTestImplementation 'androidx.test.ext:truth:1.5.0'

Expected Behavior:

Work with v1.5.0 of androidx.test libraries.

kaushal-prabhakar commented 1 year ago

I still face this issue, any solution for this yet

cdiazc commented 1 year ago

@kaushalp123 same here, I haven't found any solution myself either.

moutyque commented 1 year ago

Hello @kaushalp123 & @cdiazc , I wanted to check your issue but I am a bit lost. In which build.gradle did you added those lines ? Also, the build.gradle are written in kts and not in groovy, have you converted the files in groovy or is this just an example ?

I tried to add:

  testImplementation("androidx.test:core:1.5.0")
  androidTestImplementation("androidx.test:core:1.5.0")
  testImplementation("androidx.test:rules:1.5.0")
  androidTestImplementation("androidx.test:rules:1.5.0")
  testImplementation("androidx.test.ext:truth:1.5.0")
  androidTestImplementation("androidx.test.ext:truth:1.5.0")

To sample/build.gradle.kts, and I had no issue to synchronized

cdiazc commented 1 year ago

Hello @moutyque thank you very much for getting back to this :) Sorry for not including enough info on the original message. The dependencies are written on our build.gradle (groovy) for :app, we cannot, for now, port to kts but the project has been working with barista 4.3.0 since the beginning and is still working now but with testing libs 1.4.0. The full list as it is in our project, and working is:


androidTestImplementation('com.adevinta.android:barista:4.3.0') {
            exclude group: 'org.jetbrains.kotlin'
            exclude module: "protobuf-lite"
}

androidTestUtil 'androidx.test:orchestrator:1.4.0'

testImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'

testImplementation        'androidx.test:core:1.4.0'       
androidTestImplementation 'androidx.test:core:1.4.0'  
testImplementation        'androidx.test:rules:1.4.0'    
androidTestImplementation 'androidx.test:rules:1.4.0' 
testImplementation        'androidx.test.ext:truth:1.4.0' 
androidTestImplementation 'androidx.test.ext:truth:1.4.0'
testImplementation        'androidx.test:core-ktx:1.4.0'
androidTestImplementation 'androidx.test:core-ktx:1.4.0'

androidTestImplementation ('androidx.test.espresso:espresso-contrib:3.4.0') {
        exclude module: "protobuf-lite"
}

As soon as we change the versions to 1.5.0, the original error appears.

Thank you very much, I hope this helps !

moutyque commented 1 year ago

Hello, Ok so if I understand correctly you are using barista 4.3 in your own project. You are also using other testing libs.

androidTestUtil 'androidx.test:orchestrator:1.4.0'

testImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'

testImplementation        'androidx.test:core:1.4.0'       
androidTestImplementation 'androidx.test:core:1.4.0'  
testImplementation        'androidx.test:rules:1.4.0'    
androidTestImplementation 'androidx.test:rules:1.4.0' 
testImplementation        'androidx.test.ext:truth:1.4.0' 
androidTestImplementation 'androidx.test.ext:truth:1.4.0'
testImplementation        'androidx.test:core-ktx:1.4.0'
androidTestImplementation 'androidx.test:core-ktx:1.4.0'

androidTestImplementation ('androidx.test.espresso:espresso-contrib:3.4.0') {
        exclude module: "protobuf-lite"
}

When you are using the version 1.4.0 of those libs every thing work fine but with version 1.5.0 it does not.

If my understanding is correct I will try to reproduce then if I can fix.

cdiazc commented 1 year ago

Hello again @moutyque, thanks for your reply. What you state is exactly what I am experiencing.

moutyque commented 1 year ago

Can you share with me your full build.gradle ?

Mine look like this:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example.myapplication'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    testImplementation 'androidx.test:core:1.5.0'
    androidTestImplementation 'androidx.test:core:1.5.0'
    testImplementation 'androidx.test:rules:1.5.0'
    androidTestImplementation 'androidx.test:rules:1.5.0'
    testImplementation 'androidx.test.ext:truth:1.5.0'
    androidTestImplementation 'androidx.test.ext:truth:1.5.0'
    testImplementation 'androidx.test:core-ktx:1.5.0'
    androidTestImplementation 'androidx.test:core-ktx:1.5.0'

    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.5.1') {
        exclude module: "protobuf-lite"
    }

}

And I do not get any sync issue. However, my project is really dummy with no real code or test, so if you can provide an example to reproduce your issue it would be really useful ?

cdiazc commented 1 year ago

@moutyque I'll try with the same specific versions on my project just in case.

A question though, i cannot see barista on you dummy project gradle file, can you please try adding


androidTestImplementation('com.adevinta.android:barista:4.3.0') {
            exclude group: 'org.jetbrains.kotlin'
            exclude module: "protobuf-lite"
}

to the file you shared ?

If you need my full gradle file I can send to you on PM since it is a work project and we can later on post the important bits for the public here.

Thank you again !

cdiazc commented 1 year ago

I tested with the following configuration:

        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'junit:junit:4.13.2'
        testImplementation 'androidx.test.ext:junit:1.1.5'
        androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'

        androidTestUtil 'androidx.test:orchestrator:1.4.2'

        testImplementation 'androidx.test:runner:1.5.2'
        androidTestImplementation 'androidx.test:runner:1.5.2'

        testImplementation        'androidx.test:core:1.5.0' 
        androidTestImplementation 'androidx.test:core:1.5.0'
        testImplementation        'androidx.test:rules:1.5.0'
        androidTestImplementation 'androidx.test:rules:1.5.0'
        testImplementation        'androidx.test.ext:truth:1.5.0'
        androidTestImplementation 'androidx.test.ext:truth:1.5.0'
        testImplementation        'androidx.test:core-ktx:1.5.0'
        androidTestImplementation 'androidx.test:core-ktx:1.5.0'

        androidTestImplementation ('androidx.test.espresso:espresso-contrib:3.5.1') {
                exclude module: "protobuf-lite"
        }

        androidTestImplementation('com.adevinta.android:barista:4.3.0') {
            exclude group: 'org.jetbrains.kotlin'
            exclude module: "protobuf-lite"
        }

And :app gradle sync is not failing but a warning is issued, the warning though is exactly the error i was getting at the beginning:

Unresolved dependencies

Cannot find a version of 'androidx.test:core' that satisfies the version constraints:
   Dependency path 'Flat:app:unspecified' --> 'androidx.test:core:1.5.0'
   Constraint path 'Flat:app:unspecified' --> 'androidx.test:core:{strictly 1.4.0}' because of the following reason: productionDebugRuntimeClasspath uses version 1.4.0
   Dependency path 'Flat:app:unspecified' --> 'androidx.test.ext:truth:1.5.0' (runtime) --> 'androidx.test:core:1.5.0'
   Dependency path 'Flat:app:unspecified' --> 'androidx.test.ext:junit-ktx:1.1.4' (runtime) --> 'androidx.test.ext:junit:1.1.4' (runtime) --> 'androidx.test:core:1.5.0'
   Dependency path 'Flat:app:unspecified' --> 'androidx.test.espresso:espresso-contrib:3.5.0' (runtime) --> 'androidx.test.espresso:espresso-core:3.5.0' (runtime) --> 'androidx.test:core:1.5.0'
   Dependency path 'Flat:app:unspecified' --> 'com.adevinta.android:barista:4.3.0' (releaseRuntimePublication) --> 'androidx.test.espresso:espresso-intents:3.4.0' (runtime) --> 'androidx.test:core:1.4.0'

As so:

image

At this point I'm wondering if there is a mixture of mismatched versions and wrong configurations, I must confess I am confused.

moutyque commented 1 year ago

I tried this and I got no issue:



plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example.myapplication'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    testImplementation 'androidx.test:core:1.5.0'
    androidTestImplementation 'androidx.test:core:1.5.0'
    testImplementation 'androidx.test:rules:1.5.0'
    androidTestImplementation 'androidx.test:rules:1.5.0'
    testImplementation 'androidx.test.ext:truth:1.5.0'
    androidTestImplementation 'androidx.test.ext:truth:1.5.0'
    testImplementation 'androidx.test:core-ktx:1.5.0'
    androidTestImplementation 'androidx.test:core-ktx:1.5.0'

    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.5.1') {
        exclude module: "protobuf-lite"
    }

    androidTestImplementation('com.adevinta.android:barista:4.3.0') {
        exclude group: 'org.jetbrains.kotlin'
        exclude module: "protobuf-lite"
    }

}
cdiazc commented 1 year ago

I'll try to find time these days to test with different values, it's pretty strange. On the meantime @moutyque are you ok with me emailing you the whole build.gradle ?

moutyque commented 1 year ago

Sure: azfboom@gmail.com

byates-fleetian commented 1 year ago

Any conclusion to this? I am also running into this issue.

cdiazc commented 1 year ago

I know this might not be the most useful message but I kept updating all my dependencies to the last available and at some point it just stopped displaying the message. I hope you projects allow this, for now those are my test deps if it could help anyone:

        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'junit:junit:4.13.2'
        testImplementation 'androidx.test.ext:junit:1.1.5' 
        androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'

        androidTestUtil 'androidx.test:orchestrator:1.4.2' 

        testImplementation 'androidx.test:runner:1.5.2'    
        androidTestImplementation 'androidx.test:runner:1.5.2'

        testImplementation        'androidx.test:core:1.5.0' 
        androidTestImplementation 'androidx.test:core:1.5.0' 
        testImplementation        'androidx.test:rules:1.5.0'  
        androidTestImplementation 'androidx.test:rules:1.5.0' 
        testImplementation        'androidx.test.ext:truth:1.5.0'
        androidTestImplementation 'androidx.test.ext:truth:1.5.0'
        testImplementation        'androidx.test:core-ktx:1.5.0'
        androidTestImplementation 'androidx.test:core-ktx:1.5.0'

        androidTestImplementation ('androidx.test.espresso:espresso-contrib:3.5.1') {
                exclude module: "protobuf-lite"
        }

        androidTestImplementation('com.adevinta.android:barista:4.3.0') {
            exclude group: 'org.jetbrains.kotlin'
            exclude module: "protobuf-lite"
        }

        testImplementation 'androidx.arch.core:core-testing:2.2.0'

        testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1'

        testImplementation 'io.mockk:mockk:1.13.5'

        testImplementation 'app.cash.turbine:turbine:0.13.0'
byates-fleetian commented 1 year ago

For what it is worth I needed only androidTestImplementation and debugImplementation

cdiazc commented 1 year ago

@byates-fleetian are you saying that those versions worked for you to fix the problem ?