为testAndroid设置与主应用程序不同的minSdkVersion [英] Set different minSdkVersion for testAndroid than for main app
问题描述
是否可以为测试设置与应用程序本身不同的 minSdkVersion
?我问是因为我想使用新的测试支持库和UI Automator进行测试.但是,这仅在API 18+上可用.同时,尽管还没有经过全面测试,我仍然希望支持旧版本的Android.为此,我需要添加什么到我的 build.gradle
文件中?
Is it possible to set a different minSdkVersion
for tests than for the app itself? I ask because I want to use the new Test Support Library and UI Automator for testing. However, this is only available on API 18+. At the same time, I still want to support older versions of Android, albeit not as thoroughly tested. What do I need to add to my build.gradle
file in order to do this?
为澄清起见,我使用的是Android Studio和基于Gradle的新"项目结构.
To clarify, I am using Android Studio and the "new" Gradle-based project structure.
推荐答案
我从新测试模板.
在 test
或 androidTest
文件夹中创建一个新的 AndroidManifest.xml
文件.
Create a new AndroidManifest.xml
file in your test
or androidTest
folder.
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:tools="http://schemas.android.com/tools"
package="your.package.name">
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/>
</manifest>
这篇关于为testAndroid设置与主应用程序不同的minSdkVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!