2

The UiAutomator v2.+ version supports only SDK level 18+ and according to documentation uiautomator shipped first with SDK Level 16. I need a way to include that version in my gradle file rather than v2.1.1. androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'

Lavekush Agrawal
  • 6,040
  • 7
  • 52
  • 85
mehmetg
  • 197
  • 1
  • 4
  • 16
  • you should comment if suggested solution resolved the problem. If yes, please accept answer so other can benefit as well. Cheers – Ewoks Nov 16 '15 at 11:06
  • As it arrived many months after the questions I must have overlooked it. No, it does not solve my problem. I have addressed the problem using build flavors. – mehmetg Nov 18 '15 at 00:39
  • Please describe in answers how you did it, so others can benefit. Thanks :) – Ewoks Nov 18 '15 at 08:11
  • As the approach suggested in the answer seemed not viable I ended up using this: http://stackoverflow.com/questions/16737006/using-build-flavors-structuring-source-folders-and-build-gradle-correctly – mehmetg Nov 25 '15 at 19:31

1 Answers1

2

Add this specific AndroidManifest.xml into androidTest folder

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="your.package">

    <uses-sdk
        android:targetSdkVersion="22"
        android:minSdkVersion="16"
        tools:overrideLibrary="android.support.test.uiautomator.v18"/>

</manifest>

Trick here is done with:

tools:overrideLibrary marker

A special marker that can only be used with uses-sdk declaration to override importing a library which minimum SDK version is more recent than that application's minimum SDK version. Without such a marker, the manifest merger will fail. The marker will allow users to select which libraries can be imported ignoring the minimum SDK version.

Renaud Mathieu
  • 366
  • 2
  • 9