blipinsk / disable-animations-rule

JUnit TestRule for Android instrumented tests, which automatically disables and enables animations
Apache License 2.0
32 stars 3 forks source link

Conflicts with AndroidX #1

Closed inhaledesign closed 4 years ago

inhaledesign commented 5 years ago

Getting the following error:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:checkDebugAndroidTestDuplicateClasses'. 1 exception was raised by workers: java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class androidx.test.uiautomator.AccessibilityNodeInfoDumper found in modules classes.jar (androidx.test.uiautomator:uiautomator:2.2.0) and classes.jar (com.android.support.test.uiautomator:uiautomator-v18:2.1.3) Duplicate class androidx.test.uiautomator.AccessibilityNodeInfoHelper found in modules classes.jar (androidx.test.uiautomator:uiautomator:2.2.0) and classes.jar (com.android.support.test.uiaDuplicate class androidx.test.uiautomator.ByMatcher found in modules classes.jar (androidx.test.uiautomator:uiautomator:2.2.0) and classes.jar (com.android.support.test.uiautomator:uiautomator-v18:2.1.3) Duplicate class androidx.test.uiautomator.ByMatcher$PartialMatch found in modules classes.jar (androidx.test.uiautomator:uiautomator:2.2.0) and classes.jar (com.android.support.test.uiautomator:uiautomator-v18:2.1.3) Duplicate class androidx.test.uiautomator.ByMatcher$SinglyLinkedList found in modules classes.jar (androidx.test.uiautomator:uiautomator:2.2.0) and classes.jar (com.android.support.test.uiautomator:uiautomator-v18:2.1.3) Duplicate class androidx.test.uiautomator.ByMatcher$SinglyLinkedList$1 found in modules classes.jar (androidx.test.uiautomator:uiautomator:2.2.0) and classes.jar (com.android.support.test.uiautomator:uiautomator-v18:2.1.3)

...and about twenty more similar lines.

I'm sure I can mange the conflicts in Gradle, but would be nice to not have to.

blipinsk commented 5 years ago

and what's your gradle setup that causes those conflicts? are you sure it's related to this library?

inhaledesign commented 5 years ago

I'm positive it's this library. Everything else I use for testing that uses UIAutomator strictly uses the AndroidX package

androidTestImplementation "androidx.test.uiautomator:uiautomator:$uiautomator_version"

This library does not use it: https://github.com/blipinsk/disable-animations-rule/blob/da80cc29b0ea3f7d0aedf58b77a38b74d1b8951d/disable-animations-rule/build.gradle#L16

I'm not really sure what the right fix is, or if it needs to be fixed. But it seems like supporting AndroidX would be a good idea.

blipinsk commented 5 years ago

I'm not really sure what the right fix is, or if it needs to be fixed. But it seems like supporting AndroidX would be a good idea.

I see no problem in doing that. It's just interesting that the jetifier does not seem to be working for androidTest dependencies then... 🤔

Thanks for reporting that 💪

inhaledesign commented 5 years ago

For reference, here's my gradle file:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    testOptions {
        animationsDisabled true
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation project(path: ":utils")
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
    implementation "org.jetbrains.anko:anko:$anko_version"

    androidTestUtil 'androidx.test:orchestrator:1.2.0'
    androidTestImplementation project(path: ":utilstestandroid")
    androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
    androidTestImplementation "androidx.test.uiautomator:uiautomator:$uiautomator_version"
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test:rules:1.2.0'
    androidTestImplementation 'com.bartoszlipinski:disable-animations-rule:1.0.0'

}
sovvly commented 4 years ago

The same problem with my project: "Duplicate class androidx.test.uiautomator...." when I add androidTestImplementation 'com.bartoszlipinski:disable-animations-rule:1.0.0'

blipinsk commented 4 years ago

@inhaledesign @sovvly version 2.0.0 includes androidx dependencies. Thanks!