Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android library is not working with Java 8

Problem

Since I switched to Java 8 in Android Studio 3.0 the ShineButton library is not working in my project anymore.


java.lang.NoClassDefFoundError: Failed resolution of: Landroid/animation/Animator$AnimatorListener$$CC;

I receive this error when using a ShineButton in my application at this part of the library exactly. Since this error occurred with my update to Java 8 and I read about some similar error with Java 8 I am quite sure that it is the factor, which causes the problem.

Goal

I would love to have a solution that allows the library to work with Java 8, because I like both the library and the functions that Java 8 delivers. I am not quite sure how to tackle this problem because i could not find any information on the NoClassDefFoundError and which exact relationship it has to Java 8.

Extra Information

I am building my project in Android Studio 3.0 Canary 4 in Android O and I am using version 0.1.7 of ShineButton.

The error occurs when pressing a ShineButton with it executing its animation.

I already issued this on GitHub, but I have not seen any response to my own nor even older issues. Recently I also started an issue to the Android developer team.

like image 808
creativecreatorormaybenot Avatar asked Oct 18 '22 10:10

creativecreatorormaybenot


1 Answers

open D8 in gradle.properties

android.enableD8.desugaring= true
android.enableD8=true

see:https://jakewharton.com/androids-java-8-support/

Or Code like below:

private Animator.AnimatorListener mAnimatorListener = new Animator.AnimatorListener() {

    @Override
    public void onAnimationStart(Animator animation, boolean isReverse) {

    }

    @Override
    public void onAnimationEnd(Animator animation, boolean isReverse) {

    }

    @Override
    public void onAnimationStart(Animator animation) {

    }

    @Override
    public void onAnimationEnd(Animator animation) {

    }

    @Override
    public void onAnimationCancel(Animator animation) {

    }

    @Override
    public void onAnimationRepeat(Animator animation) {

    }

the key is override:

@Override
public void onAnimationStart(Animator animation, boolean isReverse) {

}

@Override
public void onAnimationEnd(Animator animation, boolean isReverse) {

}
like image 53
Ado Avatar answered Oct 21 '22 08:10

Ado