当我发布带有混淆功能的应用程序时,无法正常工作 膨胀 class 按钮时出错。仅使用混淆器

When I release the app with ofuscation dosen´t work properly Error inflating class button. Only with ofuscation

正如您在代码中看到的那样,我的应用程序非常简单,几乎没有依赖项。如果我通过制作 ture minifyEneble 使用混淆,它只会抛出异常。对不起是我的英语。

我的 gradle 在这里:

android {
    compileSdkVersion 25
    defaultConfig {
        applicationId "cu..."
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 220
        versionName "2.2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleDependency
    implementation 'com.android.support:appcompat-v7:25.3.1'
    //noinspection GradleDependency
    implementation 'com.android.support:design:25.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}

一些常见的XML:

<?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:itemTextColor="@color/colorPrimary"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

    </android.support.v4.widget.DrawerLayout>

Style.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme1" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">#d74c91</item>
        <item name="colorPrimaryDark">#b6065d</item>
        <item name="colorAccent">#eefb20</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

样式-21.xml:

<resources>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:statusBarColor">@color/colorPrimaryDark</item>

    </style>
</resources>

我看到了一些答案,但对我不起作用,因为它只在我使用混淆时出现。

谢谢,已经用这个规则解决了:

-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; } 
-keep public class android.support.v7.internal.view.menu.**