Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load class OutputFileTask with Android Studio 1.2 and Gradle 1.2.2

After upgrading to Android Studio 1.2, I´m getting the following error when trying to sync my project

Error:Unable to load class 'com.android.build.gradle.internal.tasks.OutputFileTask'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

This is my gradle file

apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'maven-publish'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    repositories {
        mavenCentral()
    }

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            consumerProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LGPL2.1'
    }
}


dependencies {
    compile 'com.android.support:support-v4:22.1.0'
    compile 'com.android.support:appcompat-v7:22.1.0'
}

task sourceJar(type: Jar) {
    classifier "source"
}



publishing {
    publications {

        repositories.maven {
            url repo
            credentials {
                username user
                password passwd
            }
        }

        maven(MavenPublication) {
            artifacts {
                groupId 'com.android'
                artifactId 'artefact-1'
                version '1'
                artifact artifactPath
            }
        }
    }

}

}

I think there could be yet another gradle api change which is causing the old stuff to not work anymore.

How can I solve the problem to build my project again?

like image 898
Marian Klühspies Avatar asked May 03 '15 18:05

Marian Klühspies


1 Answers

Are you using dexguard? I had the issue with an old dexguard version. Since I updated to 6.1.19 there is no issue anymore. (Currently using AS 1.2.1 & Gradle 2.4 & 1.2.3)

like image 133
Patrick Favre Avatar answered Sep 29 '22 17:09

Patrick Favre