Android tests build error: Multiple dex files define Landroid/support/test/BuildConfig

前端 未结 7 2343
逝去的感伤
逝去的感伤 2020-12-01 05:02

I\'m trying to add Espresso 2 to my project (which also has lots of other dependencies), but I\'m hitting this error when trying to run tests:

UNEXPECTED TOP         


        
7条回答
  •  我在风中等你
    2020-12-01 05:22

    One other useful tip is how to force dependency resolution to a specific version.

    Here is one way:

    configurations.all {
        resolutionStrategy.force 'com.android.support:support-annotations:22.0.0'
    }
    

    ...and here is another:

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'com.android.support') {
                details.useVersion '22.0.0'
            }
        }
    }
    

    Using either of these with com.android.support.test.espresso:espresso-core:2.1 should work.

    See the Forcing consistent version for a group of libraries section in the Gradle documentation for more information.

提交回复
热议问题