Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI Automator in project with minSdkVersion 9

im trying to use UI Automator in my project with minSdkVersion 9 and of course it not work because it target API 18.

So Android Studio throws me this error:

Error:(5, 5) uses-sdk:minSdkVersion 9 cannot be smaller than version 18 declared in library ~/app/build/intermediates/exploded-aar/com.android.support.test.uiautomator/uiautomator-v18/2.1.1/AndroidManifest.xml

Suggestion: use tools:overrideLibrary="android.support.test.uiautomator.v18" to force usage

Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 18 declared in library ~/app/build/intermediates/exploded-aar/com.android.support.test.uiautomator/uiautomator-v18/2.1.1/AndroidManifest.xml

    Suggestion: use tools:overrideLibrary="android.support.test.uiautomator.v18" to force usage

I added to my Manifest the tag <uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18" /> but the error keep showing, i am doing something wrong?

like image 524
rafael Avatar asked Aug 03 '15 17:08

rafael


People also ask

What is UI Automator in Appium?

UIAutomator 2 is an automation framework based on Android instrumentation and allows one to build and run UI tests. Appium uses Google's UIAutomator to execute commands on real devices and emulators. UIAutomator is Google's test framework for native app automation at the UI level.

Where is UI Automator?

Some properties, like the text, are visible to the user, but there are several others that we cannot see on the device screen, so we need to dump the screen using the UI Automator Viewer tool that is available in the Android SDK at $ANDROID_HOME/tools/bin/uiautomatorviewer .

Where is Uiautomatorviewer located?

opening uiautomatorviewer. bat file in the Android installation folder with the following command: Android >> Android-SDK >> Tools >> UIAutomatorViewer.


2 Answers

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.

like image 134
David Medenjak Avatar answered Nov 07 '22 11:11

David Medenjak


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" />

like image 2
Morteza Rastgoo Avatar answered Nov 07 '22 12:11

Morteza Rastgoo