Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error: Could not resolve org.jacoco:org.jacoco.agent

FAILURE: Build failed with an exception.

  • What went wrong: Could not resolve all dependencies for configuration ':app:androidJacocoAgent'.

Could not resolve org.jacoco:org.jacoco.agent:0.7.5.201505241946. Required by: MYAPP:app:unspecified No cached version of org.jacoco:org.jacoco.agent:0.7.5.201505241946 available for offline mode. No cached version of Blockquote

My project's build.gradle looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/ASL2.0'
    }
    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 8
        versionName '2.0.6 BETA'
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'io.reactivex:rxandroid:1.0.1'
    compile 'com.squareup.retrofit2:retrofit-adapters:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
}
like image 536
Yurii Bulan Avatar asked Sep 20 '16 07:09

Yurii Bulan


People also ask

What is jacocoTestReport?

JaCoCo Report configurationThe JacocoReport task can be used to generate code coverage reports in different formats. It implements the standard Gradle type Reporting and exposes a report container of type JacocoReportsContainer. Example 4. Configuring test task. build.gradle.


2 Answers

It looks like some dependency needs org.jacoco:org.jacoco.agent:0.7.5.201505241946 as a dependency, but can't find it for some reason. It can be found in the maven repository side so it does exist. Add this line: compile group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.7.5.201505241946' to your dependencies list, so it will look like this:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.7.5.201505241946'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'io.reactivex:rxandroid:1.0.1'
    compile 'com.squareup.retrofit2:retrofit-adapters:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
}

This will add the dependency to your project and cut out the middle man so to speak.

like image 141
Luke Melaia Avatar answered Oct 12 '22 09:10

Luke Melaia


For me it happened because android studio actually entered offline mode somehow. After disabling offline mode (Settings->Build, Execution, Deployment-> Gradle-> Offline work) dependency was successfully retrieved.

like image 41
shtolik Avatar answered Oct 12 '22 10:10

shtolik