WebRtc/Android 的 minifyEnabled 启用和 proguard 问题用于发布打包

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

我在build.gradle中设置了以下内容:

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

在进行发布构建时,我 运行 喜欢这个:

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.

如何解决这个问题?

这意味着在执行 progaurd 期间,这些方法从 android.media.AudioTrack 中剥离。

您可以阻止警告继续执行:

-dontwarn org.webrtc.voiceengine.WebRtcAudioTrack

或者保留缺少方法的 class,这样 proguard 就不会碰它:

-keep android.media.AudioTrack