【问题标题】:minifyEnabled enabled and proguard issue with WebRtc/Android for release packaging用于发布打包的 WebRtc/Android 启用了 minifyEnabled 和 proguard 问题
【发布时间】:2017-03-28 18:04:52
【问题描述】:

我在 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.

如何解决这个问题?

【问题讨论】:

    标签: android webrtc android-proguard dex


    【解决方案1】:

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

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

    -dontwarn org.webrtc.voiceengine.WebRtcAudioTrack

    或者保留缺少方法的类,以便 proguard 不会触及它:

    -keep android.media.AudioTrack

    【讨论】:

    • 谢谢,-dontwarn org.webrtc.voiceengine.WebRtcAudioTrack 为我工作。
    • @Rod_Algonquin 为什么 -keep android.media.AudioTrack 不起作用?
    猜你喜欢
    • 1970-01-01
    • 2017-10-16
    • 1970-01-01
    • 1970-01-01
    • 2018-08-02
    • 2016-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多