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?
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.
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 .
opening uiautomatorviewer. bat file in the Android installation folder with the following command: Android >> Android-SDK >> Tools >> UIAutomatorViewer.
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With