当我使用 ofuscation 发布应用程序时,无法正常工作 错误膨胀类按钮仅与滥用

问题描述

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

我的毕业证书:

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>

样式.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>

Style-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.**

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...