How to use tools:overrideLibrary with multiple libraries

自闭症网瘾萝莉.ら 提交于 2019-11-30 03:13:43

I have found out that the solution is to create a second AndroidManifest.xml, just for the tests. It has to be saved into the tests directory and needs to contain only the overrideLibrary statement:

<?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="${applicationId}">
    <uses-sdk tools:overrideLibrary="android.app, android.support.test, android.support.test.rule, android.support.test.espresso, android.support.test.espresso.idling, android.support.test.uiautomator.v18"/>
</manifest>

If you are using a different directory for your tasks, you can specify it this way in your gradle file:

androidTest.setRoot('src_test_uiautomator')

The AndroidManifest.xml file has to be in the root of that directory, the test sources in the "java" subdirectory.

According to official doc(section Merge conflict marker for imported libraries), it should be.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.android.example.app"
   xmlns:tools="http://schemas.android.com/tools">
   ...
   <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="2"
             tools:overrideLibrary="com.example.lib1, com.example.lib2"/>

where com.example.lib1, com.example.lib2 are the packages declared in the AndroidManifes inside the libraries.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!