- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 gradle 构建我的 android 应用程序。
我按照文档 ( https://developer.android.com/topic/libraries/testing-support-library/index.html ) 来定义依赖项。
但是,gradle build
总是说找不到一些依赖。
> Could not resolve all dependencies for configuration ':_debugAndroidTestCompile'.
> Could not find junit:junit:4.12.
Searched in the following locations:
file:/home/tumh/android-sdk-linux/extras/android/m2repository/junit/junit/4.12/junit-4.12.pom
file:/home/tumh/android-sdk-linux/extras/android/m2repository/junit/junit/4.12/junit-4.12.jar
file:/home/tumh/android-sdk-linux/extras/google/m2repository/junit/junit/4.12/junit-4.12.pom
file:/home/tumh/android-sdk-linux/extras/google/m2repository/junit/junit/4.12/junit-4.12.jar
Required by:
:myapp:unspecified
:myapp:unspecified > com.android.support.test:runner:0.4.1
> Could not find com.squareup:javawriter:2.1.1.
Searched in the following locations:
file:/home/tumh/android-sdk-linux/extras/android/m2repository/com/squareup/javawriter/2.1.1/javawriter-2.1.1.pom
file:/home/tumh/android-sdk-linux/extras/android/m2repository/com/squareup/javawriter/2.1.1/javawriter-2.1.1.jar
file:/home/tumh/android-sdk-linux/extras/google/m2repository/com/squareup/javawriter/2.1.1/javawriter-2.1.1.pom
file:/home/tumh/android-sdk-linux/extras/google/m2repository/com/squareup/javawriter/2.1.1/javawriter-2.1.1.jar
Required by:
:myapp:unspecified > com.android.support.test.espresso:espresso-core:2.2.1
> Could not find javax.inject:javax.inject:1.
Searched in the following locations:
file:/home/tumh/android-sdk-linux/extras/android/m2repository/javax/inject/javax.inject/1/javax.inject-1.pom
file:/home/tumh/android-sdk-linux/extras/android/m2repository/javax/inject/javax.inject/1/javax.inject-1.jar
file:/home/tumh/android-sdk-linux/extras/google/m2repository/javax/inject/javax.inject/1/javax.inject-1.pom
file:/home/tumh/android-sdk-linux/extras/google/m2repository/javax/inject/javax.inject/1/javax.inject-1.jar
Required by:
:myapp:unspecified > com.android.support.test.espresso:espresso-core:2.2.1
> Could not find org.hamcrest:hamcrest-library:1.3.
Searched in the following locations:
file:/home/tumh/android-sdk-linux/extras/android/m2repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.pom
file:/home/tumh/android-sdk-linux/extras/android/m2repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar
file:/home/tumh/android-sdk-linux/extras/google/m2repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.pom
file:/home/tumh/android-sdk-linux/extras/google/m2repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar
Required by:
:myapp:unspecified > com.android.support.test.espresso:espresso-core:2.2.1
> Could not find org.hamcrest:hamcrest-integration:1.3.
Searched in the following locations:
file:/home/tumh/android-sdk-linux/extras/android/m2repository/org/hamcrest/hamcrest-integration/1.3/hamcrest-integration-1.3.pom
file:/home/tumh/android-sdk-linux/extras/android/m2repository/org/hamcrest/hamcrest-integration/1.3/hamcrest-integration-1.3.jar
file:/home/tumh/android-sdk-linux/extras/google/m2repository/org/hamcrest/hamcrest-integration/1.3/hamcrest-integration-1.3.pom
file:/home/tumh/android-sdk-linux/extras/google/m2repository/org/hamcrest/hamcrest-integration/1.3/hamcrest-integration-1.3.jar
Required by:
:myapp:unspecified > com.android.support.test.espresso:espresso-core:2.2.1
> Could not find com.google.code.findbugs:jsr305:2.0.1.
Searched in the following locations:
file:/home/tumh/android-sdk-linux/extras/android/m2repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.pom
file:/home/tumh/android-sdk-linux/extras/android/m2repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
file:/home/tumh/android-sdk-linux/extras/google/m2repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.pom
file:/home/tumh/android-sdk-linux/extras/google/m2repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
Required by:
:myapp:unspecified > com.android.support.test.espresso:espresso-core:2.2.1
> Could not find javax.annotation:javax.annotation-api:1.2.
Searched in the following locations:
file:/home/tumh/android-sdk-linux/extras/android/m2repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.pom
file:/home/tumh/android-sdk-linux/extras/android/m2repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
file:/home/tumh/android-sdk-linux/extras/google/m2repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.pom
file:/home/tumh/android-sdk-linux/extras/google/m2repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
Required by:
:myapp:unspecified > com.android.support.test.espresso:espresso-core:2.2.1
Here is the gradle script
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
android {
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileSdkVersion "android-22"
buildToolsVersion "20.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
}
androidTest.setRoot('tests')
}
dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.4.1'
// 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'
}
}
即使我在 androidTestCompile 中指定了 junit 4.12,它仍然通过 $android_sdk_home
搜索库,但不是预期的 maven central。
谢谢!
最佳答案
更新:我认为问题是您需要在 buildscript 部分之外的另一个 repositories{mavenCentral()} 部分。我总是为此使用根脚本,但我不确定。你所有的脚本看起来都很奇怪,请阅读 this :
buildscript { ... } configures the code driving the build. In this case, this declares that it uses the Maven Central repository, and that there is a classpath dependency on a Maven artifact. This artifact is the library that contains the Android plugin for Gradle in version 0.11.1 Note: This only affects the code running the build, not the project. The project itself needs to declare its own repositories and dependencies. This will be covered later.
之前的回复:其他可能的问题:
替换
compileSdkVersion "android-22"
通过
compileSdkVersion 22
并且需要安装使用更高版本的build tools 22.0.1+
Note: Always use a build tools version whose major revision number is higher or equal to that of your compilation target and target SDK.
并将依赖项 block 移动到 android block 之外,如 here .
The dependencies element is outside and after the android element.
关于 Espresso 的更多信息 here .
我不知道确切的问题抱歉,请尝试 working sample首先,或者等待更好的响应。
关于android - 如何设置与 AndroidJunitRunner 的依赖关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33339287/
我在我的项目中使用 AndroidJUnitRunner,但无论是在 Android Studio 中还是通过 gradlew 从命令行在设备和模拟器上执行单元测试都非常慢。 我正在使用这个开源项目的
只要指定类,我就可以运行仪器测试。 adb shell am instrument -w -e class com.application.instrumentation.BaseActivityTe
我使用 gradle 构建我的 android 应用程序。 我按照文档 ( https://developer.android.com/topic/libraries/testing-support-
设置: 我继承的一个较旧的项目有很多遗留的仪器测试,我想对它们施加超时,因为它们中的很多都可以无限期地挂起,这使得很难获得测试报告。我正在将测试更新为 Junit4 样式,但目前它们都在扩展 Acti
我有一个 Android 应用程序,我正在尝试使用 Jenkins 进行设置。我已经使用 Android 模拟器插件启动模拟器,并使用 gradle 脚本构建项目,但我无法让它运行我使用 Androi
我是 Android 测试领域的新手,单元测试示例提到了 AndroidJunit4 runner 的使用。我偶然发现了另一个名为 AndroidJUnitRunner 的运行者。现在,我看到了这两个
我正在尝试整合 Espresso 2.0's AndoridJUnitRunner与 ActivityUnitTestCase。但是,当 startActivity() tries to initia
在 Gradle 和 Run/Debug Configurations -> Android Tests -> MyInstrumentedTest -> General -> Specific in
我想使用 faSTLane screengrab,当我启动时 fastlane screengrab我有这个错误:android.util.AndroidException: INSTRUMENTAT
我们围绕相机功能进行了一些 UI 测试,在我们从 InstrumentationTestRunner 切换到 AndroidJUnitRunner 作为迁移到 Espresso/JUnit4 的一部分
我正在尝试使用插桩测试,并将我的项目更新为 AndroidX。但是在尝试运行时出现以下错误: 2018-10-09 14:22:29.468 13263-13263/xxx.yyy E/Android
我是仪器测试的新手。我正在尝试使用 AndroidJUnitRunner 进行基本测试。这是我的毕业典礼: apply plugin: 'com.android.application' androi
我正在尝试将我的项目更新为最近发布的 Android 测试支持库版本 1.0.0。但是,如果我添加 assertj-core 依赖项,Gradle 检测的测试任务开始失败,并显示“未找到测试”消息。不
我已经编写了一个简单的 Android 工具测试用例来测试网络操作。 Test case class name: Main3ActivityTest.java Method name:addNewEm
我尝试在 MultiDex 应用程序上运行 Espresso 测试,但失败并出现以下错误 Error:Execution failed for task > :transformClassesWith
几天以来,我一直在为我们的 MultiDex 应用程序中的 NoClassDefFoundError 和 AndroidJUnitRunner 而苦苦挣扎...... 因为我们想开始使用 Espres
我们将 Robotium 与 android.test.InstrumentationTestRunner 一起用于我们的测试。尽管如此,我们还是想用 Espresso 替换 Robotium,但我们
我在单元测试中使用了 robolectric。最近在我们的项目中,我们添加了一个来自 zendesk 的新依赖项。 repositories { maven { url 'ht
在我的应用程序上录制了一个简单的 Espresso 测试后,测试无法运行,我希望有人能指导我了解为什么会发生这种情况。产生的错误是: D/AndroidJUnitRunner: Use the raw
我是一名优秀的程序员,十分优秀!