FloatingActionButton与SnackBar和CoordinatorLayout在使用proguard后无法工作

8
这段简单的代码在启用proguard后无法按预期工作:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinator_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/show"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_marginTop="40dp"
        android:text="Show snackbar" />


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        android:src="@drawable/ic_save_white_24dp"
        app:layout_anchorGravity="bottom|right|end" />


</android.support.design.widget.CoordinatorLayout>

期望的行为是当 FloatingActionButton 显示时将其推动到 SnackBar 上方,但在禁用 proguard 前这并没有发生。
目前还没有教程涵盖此问题,因为新项目默认已禁用 proguard ;)
有人知道 Design Support Library 的 proguard 配置吗?
2个回答

6

试试这个:

# support design
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }

对我来说不起作用。请检查这个问题[启用Proguard文件后默认主题无法正常工作](https://dev59.com/rJPfa4cB1Zd3GeqPKfop) - Ibrahim Disouki

3

谷歌已经通过AAR中嵌入的ProGuard配置修复了这个漏洞。只需在build.gradle中更新设计库依赖项至23+即可。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接