UI Automator in project with minSdkVersion 9 UI Automator in project with minSdkVersion 9 android android

UI Automator in project with minSdkVersion 9


If you use gradle you can add another Manifest to the androidTest build type which will get merged and does not affect your normal release / debug builds.

Add app/src/androidTest/AndroidManifest.xml to your project:

<manifest    package="${applicationId}.test"    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools">    <uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/></manifest>

This will merge the manifest with your normal one, not requiring to change your minSdk. PLease note, that this will probably crash if you try running UI Instrumentation Tests on sdk < 18.

By adding additional permissions to the debug/AndroidManifest you can also just add permissions for your tests like external storage if you don't regularly need them in your app. They will although be also available to your debug builds.


This worked for me

<manifest xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"package="${applicationId}.test"><uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator" />


You need to build your app with minSdkVersion 18, however you can still switch to espresso.