D
D
Davron Fayziev2018-03-10 16:35:14
Android
Davron Fayziev, 2018-03-10 16:35:14

There is a problem with the application, how can I fix it?

Good afternoon dear developers!
I wanted to make an animated gradient background like instagram
It works fine on all phones without problems, but when you open the application on MEIZU and XIAOMI Smartphones, it gives an error and the application closes immediately
The error itself

android.content.res.Resources$NotFoundException: File res/drawable/anim_list.xml from drawable 
    resource ID 0x7f07005a

In OnCreate I do
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
              _gradientLayout = (RelativeLayout) findViewById(R.id.splash_layout);
              _gradientLayout.setBackgroundResource(R.drawable.anim_list);
              anim = (AnimationDrawable) rl.getBackground();
              anim.setExitFadeDuration(1000);
        }

anim_list.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@drawable/first_gradient"
        android:duration="2000" />

    <item
        android:drawable="@drawable/second_gradient"
        android:duration="3000" />

</animation-list>

first_gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:angle="45"
        android:endColor="#0b648e"
        android:startColor="#0b3549" />
</shape>

second_gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:angle="45"
        android:endColor="#0b3549"
        android:startColor="#0b648e" />
</shape>

The application works clearly on all smartphones, only XIAOMI and MEIZU give such an error.
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
betonaKilometer, 2018-03-10
@betonaKilometer

"In OnCreate I do" should be wrapped in a try catch. It should no longer fall at startup.
Then for these models, with which there are problems - set where the "res/drawable/anim_list.xml" has gone.
And in case of an error, execute the code that finds it. If possible, filter by model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question