Video View not working under Proguard

Viewed 625

There seems to be a problem in VideoView which doesn't work under Proguard. The following screen comes when a video is being started.

VideoView Not Working in Proguard

The code for Video View is as follows:

        mediaController= new MediaController(this);
        mediaController.hide();
        mediaController.setAnchorView(video_animation);
        Uri uri= Uri.parse("android.resource://" + getPackageName() + "/"
                + R.raw.splash_min);
        video_animation.setMediaController(mediaController);
        video_animation.setVideoURI(uri);
        video_animation.requestFocus();

        video_animation.start();

Also there is no specific ProGuard setting added for VideoView to run.

Excerpts of build.gradle

buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
            resValue "string", "FB_APP_ID", getFbAppKey()
        }
        debug {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
            resValue "string", "FB_APP_ID", getFbAppKey()
        }
    }

Also there are product flavours being used just to manipulate with the application ID.

4 Answers

add keep.xml in raw folder.

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@raw/splash_min"
    />

I'm not sure if it's still relevant to you, but it might be useful for other people. I had the same issue. In my case, the root cause is something to do with one of my library I used and proguard config.

So, I got this error when building an apk with proguard.

enter image description here

The way I tried to eliminate that error was by adding -ignorewarning. The error was solved but it made my video can't be played.

There are 2 ways to solve this issue:

  1. remove shrinkResources true from gradle

    or

  2. remove -ignorewarning and fix the warnings generated by your library.

Related