android – 启用Proguard文件后默认主题不起作用(minifyEnabled true)

android – 启用Proguard文件后默认主题不起作用(minifyEnabled true),第1张

概述这是我第一次使用Proguard文件.我开始了一个新项目,所以我可以了解更多有关Proguard File的信息. 我的问题是当我启用Proguard时出错了. 你好世界的位置错位,如下图所示: 应用程序运行而不启用Prodguard: 我的样式文件: <resources> <!-- Base application theme. --> <style name="AppThe 这是我第一次使用Proguard文件.我开始了一个新项目,所以我可以了解更多有关Proguard file的信息.
我的问题是当我启用Proguard时出错了.

你好世界的位置错位,如下图所示:

应用程序运行而不启用Prodguard:


我的样式文件:

<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="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>

我的清单文件:

<application        androID:allowBackup="true"        androID:icon="@mipmap/ic_launcher"        androID:label="@string/app_name"        androID:supportsRtl="true"        androID:theme="@style/Apptheme">        <activity            androID:name=".MainActivity"            androID:label="@string/app_name"            androID:theme="@style/Apptheme.NoActionbar">            <intent-filter>                <action androID:name="androID.intent.action.MAIN" />                <category androID:name="androID.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application>    <uses-permission androID:name="androID.permission.INTERNET" />

我的MainActivity onCreate方法:

@OverrIDe    protected voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.activity_main);        Toolbar toolbar = (Toolbar) findVIEwByID(R.ID.toolbar);        setSupportActionbar(toolbar);        floatingActionbutton fab = (floatingActionbutton) findVIEwByID(R.ID.fab);        fab.setonClickListener(new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw vIEw) {                Snackbar.make(vIEw,"Replace with your own action",Snackbar.LENGTH_LONG)                        .setAction("Action",null).show();            }        });        Log.d(TAG,"TEST!");        Log.i(TAG,"INFO!");        Log.e(TAG,"ERROR!");    }

Edite:
我的Proguard文件:

-assumenosIDeeffects class androID.util.Log {    public static int d(...);}-dontwarn androID.support.v4.**-keep public class androID.support.v7.Widget.** { *; }-keep public class androID.support.v7.internal.Widget.** { *; }-keep public class androID.support.v7.internal.vIEw.menu.** { *; }-keep public class * extends androID.support.v4.vIEw.ActionProvIDer {    public <init>(androID.content.Context);}-dontwarn androID.support.design.**-keep class androID.support.design.** { *; }-keep interface androID.support.design.** { *; }-keep public class androID.support.design.R$* { *; }

我的activity_main.xml文件:

<?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"    xmlns:tools="http://schemas.androID.com/tools"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:fitsSystemwindows="true"    tools:context="com.reviworx.workingwithproguard.MainActivity">    <androID.support.design.Widget.AppbarLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:theme="@style/Apptheme.AppbarOverlay">        <androID.support.v7.Widget.Toolbar            androID:ID="@+ID/toolbar"            androID:layout_wIDth="match_parent"            androID:layout_height="?attr/actionbarSize"            androID:background="?attr/colorPrimary"            app:popuptheme="@style/Apptheme.PopupOverlay" />    </androID.support.design.Widget.AppbarLayout>    <include layout="@layout/content_main" />    <androID.support.design.Widget.floatingActionbutton        androID:ID="@+ID/fab"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_gravity="bottom|end"        androID:layout_margin="@dimen/fab_margin"        androID:src="@androID:drawable/ic_dialog_email" /></androID.support.design.Widget.CoordinatorLayout>

我的content_main.xml文件:

<?xml version="1.0" enCoding="utf-8"?><relativeLayout 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:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:paddingBottom="@dimen/activity_vertical_margin"    androID:paddingleft="@dimen/activity_horizontal_margin"    androID:paddingRight="@dimen/activity_horizontal_margin"    androID:paddingtop="@dimen/activity_vertical_margin"    app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"    tools:context="com.reviworx.workingwithproguard.MainActivity"    tools:showIn="@layout/activity_main">    <TextVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="Hello World!" /></relativeLayout>
解决方法 尝试添加此功能

-keep public class * extends androID.support.design.Widget.CoordinatorLayout$Behavior {  public <init>(androID.content.Context,androID.util.AttributeSet);}
总结

以上是内存溢出为你收集整理的android – 启用Proguard文件后默认主题不起作用(minifyEnabled true)全部内容,希望文章能够帮你解决android – 启用Proguard文件后默认主题不起作用(minifyEnabled true)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1123718.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存