gpt4 book ai didi

android-studio - gradlew connectedAndroidTestFails on createDebugCoverageReport

转载 作者:行者123 更新时间:2023-12-03 17:39:26 24 4
gpt4 key购买 nike

当我运行 .gradlew createCoverageReport 时,出现以下错误:

:WFMRecipeApplication:connectedAndroidTest
Tests on Nexus 5 - 4.4.4 failed: Instrumentation run failed due to 'java.lang.VerifyError'
11:36:00 E/Device: Error during Sync: Remote object doesn't exist!
null
java.io.IOException: Failed to pull /data/data/com.project.recipes/coverage.ec from device
at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:115)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:158)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:42)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
Caused by: com.android.ddmlib.SyncException: Remote object doesn't exist!
at com.android.ddmlib.SyncService.pullFile(SyncService.java:314)
at com.android.ddmlib.Device.pullFile(Device.java:873)
at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:108)
... 10 more
:WFMRecipeApplication:connectedAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':WFMRecipeApplication:connectedAndroidTest'.
> There were failing tests. See the report at: file:///Users/elidd1//connected/index.html

但是当我访问那个 index.html 时它看起来像这样: enter image description here

我不明白为什么它会崩溃。在此失败之前,构建已达到大约 98%。我连接了一个运行 4.4 的 nexus 5..

我的 build.gradle 看起来像这样:

apply plugin: 'android'
apply plugin: 'jacoco'
android {
compileSdkVersion 16
buildToolsVersion '19.1.0'

defaultConfig {
minSdkVersion 15
targetSdkVersion 16
versionCode 1
versionName '0.7.2'
testApplicationId "------.recipes.application.test"
testInstrumentationRunner 'android.test.InstrumentationTestRunner'
}
signingConfigs {
debug {
storeFile file('../keystore/WFM_debug.jks')
storePassword 'wfmrecipes'
keyAlias 'WFMRecipes'
keyPassword 'wfmrecipes'
}
release {
storeFile file('../keystore/WFM_release.jks')
storePassword 'wfmrecipes'
keyAlias 'WFMRecipes'
keyPassword 'wfmrecipes'
}
}
buildTypes {
release {
runProguard true
zipAlign true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
resValue "bool", "isCrittercismEnabled", "true"
resValue "bool", "isHockeyEnabled", "true"
testCoverageEnabled true

}
debug {
runProguard false
zipAlign true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.debug
resValue "bool", "isCrittercismEnabled", "false"
resValue "bool", "isHockeyEnabled", "false"
testCoverageEnabled true

}
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
sourceSets {
main { res.srcDirs = ['src/main/res', 'src/main/res/drawable', 'src/main/res/menu'] }
}
productFlavors {
}
jacoco {
toolVersion = "0.7.1.201405082137"
reportsDir = file("$buildDir/customJacocoReportDir")
}


}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':Project')
compile project(':WFMStore')
}


buildscript {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/comnewrelic-1153' }
maven { url 'https://oss.sonatype.org/content/repositories/comnewrelic-1154' }
}
dependencies {
}
}
//apply plugin: 'newrelic'

repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/comnewrelic-1153' }
}

dependencies {
compile 'com.android.support:appcompat-v7:19.+'
}
dependencies {
compile 'com.newrelic.agent.android:android-agent:+'
}

// added to cut down on the number of methods for codecoverage (limit is 65,536 and playservices hogs most of this) - elidd1
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}

afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
ResolutionResult resolution = runtimeConfiguration.incoming.resolutionResult
// Forces resolve of configuration
ModuleVersionIdentifier module = resolution.getAllComponents().find { it.moduleVersion.name.equals("play-services") }.moduleVersion

String prepareTaskName = "prepare${toCamelCase("${module.group} ${module.name} ${module.version}")}Library"
File playServiceRootFolder = project.tasks.find { it.name.equals(prepareTaskName) }.explodedDir

Task stripPlayServices = project.tasks.create(name: 'stripPlayServices', group: "Strip") {
inputs.files new File(playServiceRootFolder, "classes.jar")
outputs.dir playServiceRootFolder
description 'Strip useless packages from Google Play Services library to avoid reaching dex limit'

doLast {
copy {
from(file(new File(playServiceRootFolder, "classes.jar")))
into(file(playServiceRootFolder))
rename { fileName ->
fileName = "classes_orig.jar"
}
}
tasks.create(name: "stripPlayServices" + module.version, type: Jar) {
destinationDir = playServiceRootFolder
archiveName = "classes.jar"
from(zipTree(new File(playServiceRootFolder, "classes_orig.jar"))) {
exclude "com/google/ads/**"
exclude "com/google/android/gms/analytics/**"
exclude "com/google/android/gms/games/**"
exclude "com/google/android/gms/plus/**"
exclude "com/google/android/gms/drive/**"
exclude "com/google/android/gms/ads/**"
}
}.execute()
delete file(new File(playServiceRootFolder, "classes_orig.jar"))
}
}

project.tasks.findAll { it.name.startsWith('prepare') && it.name.endsWith('Dependencies') }.each { Task task ->
task.dependsOn stripPlayServices
}
}

最佳答案

应用插件部分导致测试无法运行。就像 Bill 建议的那样,gradle 的最新版本已将 jacoco 打包在其中,因此不再需要应用它。

我的测试最近因此而失败。删除该行解决了我的问题,我再次收到报告。

关于android-studio - gradlew connectedAndroidTestFails on createDebugCoverageReport,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26063673/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com