Search code examples
androidwebrtcandroid-proguarddex

minifyEnabled enabled and proguard issue with WebRtc/Android for release packaging


I have set the following in build.gradle:

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

While doing a release build, I am running into this:

Warning: org.webrtc.voiceengine.WebRtcAudioTrack: can't find referenced method 'int getBufferCapacityInFrames()' in library class android.media.AudioTrack
Warning: org.webrtc.voiceengine.WebRtcAudioTrack: can't find referenced method 'int getUnderrunCount()' in library class android.media.AudioTrack


Warning: there were 2 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)

Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:myapp:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':myapp:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

How to fix this?


Solution

  • It means that during the execution of progaurd those methods are stripped from android.media.AudioTrack.

    You can either prevent the warning to continue execution:

    -dontwarn org.webrtc.voiceengine.WebRtcAudioTrack

    Or keep the class that has missing methods so proguard wont touch it:

    -keep android.media.AudioTrack