android studio 单元测试问题记录
2017-01-18 16:42
309 查看
问题1:在Build Variants窗口中没有Test Artifact来选择测试器
如图:解决方案是在Menu中依次打开: File ->
Settings ->
Build, Execution, Deployment ->
Build Tools -> Gradle ->
Experimental
将Enable all test artifacts (Unit
Test and Instrumentation Test) in Android projects 取消勾选,点击OK后效果如下图
问题2:Error:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.3.0) and test app (23.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
在配置支持UI测试的时候首先添加defaultConfig { testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }其次添加
dependencies { androidTestCompile 'com.android.support.test:runner:0.4' // Set this dependency to use JUnit 4 rules androidTestCompile 'com.android.support.test:rules:0.4' // Set this dependency to build and run Espresso tests androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' // Set this dependency to build and run UI Automator tests androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' }然后提示问题2,在dependencies中添加
androidTestCompile 'com.android.support:support-annotations:23.3.0'
总共添加的代码如下
dependencies { androidTestCompile 'com.android.support.test:runner:0.4' // Set this dependency to use JUnit 4 rules androidTestCompile 'com.android.support.test:rules:0.4' // Set this dependency to build and run Espresso tests androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' // Set this dependency to build and run UI Automator tests androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' // Solves "versions for app (23.3.0) and test app (23.1.1) differ" androidTestCompile 'com.android.support:support-annotations:23.3.0' }问题2解决
相关文章推荐
- 问题文件Android Studio 安装完成不能打开等问题解决记录
- Android Studio 问题记录-全部java文件全部报错,却可以运行
- 使用Junit进行单元测试时遇到的问题记录[上]
- Android Studio开发工具相关问题记录
- Android Studio 安装完成不能打开等问题解决记录
- Android Studio使用中遇到问题解决记录
- Android 开发工具(android studio )安装中的问题记录
- Android Studio 问题记录
- 在android studio中RecyclerView的使用和遇到的问题(记录):
- 使用Android studio中遇到的各种问题记录
- Android Studio 使用NDK编程调用第三方动态库问题记录
- Android Studio中Junit单元测试使用JSON对象异常的问题
- Android Studio环境进行APk开发问题记录及解决方法记录(一)
- eclipse迁移到Android Studio 问题记录
- 记录android studio 配置遇到的各种问题
- android studio导入开源项目问题记录
- Android Studio 开发问题记录
- Android Studio 问题记录-全部java文件全部报错,却可以运行
- Android studio Import Eclipse项目 .9图 报错问题记录