I'm new to android studio and I want to animate an imageButton with a sequential animation set. The animation set (animation_boutons.xml)is in res/anim. I've tried with animationSet in java but the app crashed every time I launched the emulator. I've spent a long time looking for a solution. I hope someone can help me ! I apologize if it's something obvious.
java code:
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        configureCodeurBouton();
    }
    private void configureCodeurBouton() {
        ImageButton boutonCodeur = findViewById(R.id.boutoncodeur);
        Animation animBoutons = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.anim_boutons);
        animBoutons.setRepeatCount(Animation.INFINITE);
        boutonCodeur.setAnimation(animBoutons);
        boutonCodeur.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(MainActivity.this, codeur.class));
            }
        });
    }
}
xml code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="true"
    android:fillAfter="true">
    <rotate
        android:fromDegrees="0"
        android:toDegrees="20"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="0"
        android:duration="1000"
        />
    <rotate
        android:startOffset="1000"
        android:fromDegrees="20"
        android:toDegrees="-20"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="2000"
        />
    <rotate
        android:fromDegrees="-20"
        android:toDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="3000"
        android:duration="1000"
        />
</set>
Also, Vedprakash Wagh give me the advice to try animBoutons.setRepeatCount(Animation.INFINITE) but it has no effect).
 
    