Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewAnimationUtils fails to work

Was trying to implement the snippet below. [from developer documentation here]:

 View myView = findViewById(R.id.my_view);

// get the center for the clipping circle
int cx = (myView.getLeft() + myView.getRight()) / 2;
int cy = (myView.getTop() + myView.getBottom()) / 2;

// get the final radius for the clipping circle
int finalRadius = Math.max(myView.getWidth(), myView.getHeight());

// create the animator for this view (the start radius is zero)
Animator anim =
    ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);

// make the view visible and start the animation
myView.setVisibility(View.VISIBLE);
anim.start();

Gettting the error below. Why is it so and how can i fix this.

java.lang.NoClassDefFoundError: android.view.ViewAnimationUtils
            at dejavu.appzonegroup.com.dejavuandroid.Fragment.PeopleTabFragment$1.onItemClick(PeopleTabFragment.java:59)
            at android.widget.AdapterView.performItemClick(AdapterView.java:299)
            at android.widget.AbsListView.performItemClick(AbsListView.java:1152)
like image 430
Nosakhare Belvi Avatar asked Dec 19 '25 14:12

Nosakhare Belvi


2 Answers

ViewAnimationUtils was added in API level 21 (Lollipop 5.0). Are you testing your app on Lollipop? It will not work on older API levels. To use it you need to set min SDK to 21.

like image 122
nhasan Avatar answered Dec 22 '25 05:12

nhasan


One google search brought me this, it gives you 3 ways to solve your problem. I'll quote a few wich I think that might resolve your problem:

1) Class is not available in Java Classpath.

2) You might be running your program using jar command and class was not defined in manifest file's ClassPath attribute.

like image 42
Thealon Avatar answered Dec 22 '25 06:12

Thealon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!