CharleyGC
CharleyGC

Reputation: 337

tools:overrideLibrary not working

I'd like to use library android.support.test.uiautomator.v18in a build supporting Android back to level 11. My manifest begins:

<?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="xxxdeletedxxx"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk
        android:targetSdkVersion="23"
        android:minSdkVersion="11"
        tools:overrideLibrary="com.android.support.test.uiautomator:uiautomator-v18" />

and in build.gradle I have

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Running ./gradlew connectedCheck gives:

* What went wrong:
Execution failed for task ':app:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 11 cannot be smaller than version 18 declared in library [com.android.support.test.uiautomator:uiautomator-v18:2.1.1] /Users/ewanbenfield/AndroidStudioProjects/TM/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

Upvotes: 8

Views: 2259

Answers (3)

Ramiro G.M.
Ramiro G.M.

Reputation: 477

For any of you wondering about this problem, you have to notice the log recommendation given by the android studio. In my case I figured out the dependency inside the uses-sdk tag has to be different from the one inside the gradle.

For example, this was my implementation inside the gradle:

implementation "com.xxxx.xxxxxx:api:1.6.6"

But the required dependency according to the error log is:

<uses-sdk tools:overrideLibrary="com.xxxx.xxxxxxapi"/>

Note that the one inside the uses-sdk tag does NOT have : before the api word.

I had copied the string inside the gradle and pasted inside the uses-sdk...that was the error.

Hope this helps...happy coding!

Upvotes: 0

Wirling
Wirling

Reputation: 5375

There is probably a difference between the packages mentioned in your build.gradle and your AndroidManifest.

AndroidManifest should at least contain

<uses-sdk
    tools:overrideLibrary="com.android.support.test.uiautomator.v18"/>

and your build.gradle should contain

androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'

I recently had a similar problem where I forgot to put 'com.' in my AndroidManifest

Upvotes: 3

tomash
tomash

Reputation: 12962

It might be this bug: https://code.google.com/p/android/issues/detail?id=230777 ("build tools: processDebugManifest step fails or not depending on ordering of project dependencies")

In reported case reordering dependencies worked.

Upvotes: 1

Related Questions