Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Jack: Lambda coming from jar file need their interfaces on the classpath to be compiled, unknown interfaces are java.util.function.Consumer

Getting this on android studio 2.2.

Does anyone have a workaround?

My app build file is:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "acme.cb2"
        minSdkVersion 18
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        jackOptions {
            enabled true
        }

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:support-v4:24.1.1'
}

edit: modifid the main build file to include answer from https://stackoverflow.com/users/5753091/mohammadreza-khalifeh - but this did not help

import java.text.SimpleDateFormat

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'org.hidetake:gradle-ssh-plugin:2.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"
        }
    }
}

edit: adding:

options.compilerArgs.each { println 'option: '+it}

prints out:

option: -Xbootclasspath/a:C:\Program Files\Java\jdk1.8.0_92\jre/lib/rt.jar

It looks like the space in the path might cause a problem?

edit: trying:

options.compilerArgs << "\""+"-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"+"\""

does not work either.

like image 961
Ray Tayek Avatar asked Sep 25 '16 05:09

Ray Tayek


1 Answers

I had this problem after adding Guava library to my dependencies.

Solution was to downgrade lib version from com.google.guava:guava:21.0 to com.google.guava:guava:20.0.

Also, I'm using classpath 'com.android.tools.build:gradle:2.5.0-alpha-preview-01`

EDIT: As you don't use this library please try to change:

  • in project build.gradle
    • classpath from classpath 'com.android.tools.build:gradle:2.2.0' to com.android.tools.build:gradle:2.5.0-alpha-preview-01
  • in app build.gradle

    • from compileSdkVersion 24 to 25
    • from buildToolsVersion "24.0.2"to 25.0.2
  • in gradle-wrapper.properties

    • change version to distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-3.5-20170213202653+0000-all.zip
like image 137
piotrek1543 Avatar answered Sep 29 '22 14:09

piotrek1543