3

.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 にアクセスすると、次のようになります。 ここに画像の説明を入力

クラッシュする理由がわかりません..これが失敗する前に、ビルドは約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
    }
}
4

2 に答える 2

0

カップルのもの。

  1. 最初のエラー「'java.lang.VerifyError' が原因でインストルメンテーションの実行に失敗しました」を修正するには、ビルド ツールを 21 以降にアップグレードします。これは、修正済みの Android ビルド ツールのバグです。万歳!
  2. jacoco プラグインを適用する必要はありません。これは android gradle プラグインの一部です。必要なのは「testCoverageEnabled true」だけで、.ec ファイルが作成されます。私が知る限り、プラグインを適用しても害はありませんが、jacoco が既にそこにあるという事実を理解しておくと役に立ちます。

「reportsDir」のオーバーライドは機能しない可能性があるため、「build/outputs/reports/coverage/debug/index.html」でもレポートを探す必要があります。

于 2015-02-23T21:48:18.260 に答える