Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FloatingActionButton with SnackBar and CoordinatorLayout won't work with proguard

This simple piece of code won't work as intended with proguard enabled:

<?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>

Desired behavior is having FloatingActionButton pushed over SnackBar when it is shown, but it doesn't happen until I disable proguard.

No tutorial also covers this as the new projects has proguard disabled by default ;)

Does anybody know the proguard configuration for Design Support Library?

like image 861
Jacek Kwiecień Avatar asked Jul 22 '15 07:07

Jacek Kwiecień


2 Answers

Try this:

# support design
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
like image 83
Udit Mukherjee Avatar answered Oct 16 '22 02:10

Udit Mukherjee


Google has fixed this bug with embedded ProGuard configuration in the AAR. Just update the design library dependency to 23+ in build.gradle.

like image 38
Oasis Feng Avatar answered Oct 16 '22 01:10

Oasis Feng