将minifyEnabled设置为true

时间:2020-02-10 09:55:50

标签: android proguard

启用minifyEnabled true时应用程序崩溃。当我做出错误的申请开始正常工作。我需要在我的前卫文件中添加一些内容吗?我无法弄清楚是什么导致应用程序崩溃。

这是Gradle代码:

debug {
            manifestPlaceholders = [crashlyticsApiKey: '', mapApiKey: '']
            // Enables code shrinking, obfuscation, and optimization for only
            debuggable true
            // your project's release build type.
            minifyEnabled true
            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            buildConfigField "String", "BASE_URL", '"http://"'
            signingConfig signingConfigs.debug
        }

Logcat输出

java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:309)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.ExceptionInInitializerError
        at l.b.g.f$a.<init>(:372)
        at l.b.g.f.<init>(:19)
        at l.b.h.m.a(:32)
        at l.b.h.m.b(:42)
        at l.b.h.b.b(:56)
        at l.b.h.g.a(:32)
        at l.b.f.a.a(:135)
        at l.b.f.b$d.f(:747)
        at l.b.f.b.b(:250)
        at d.k.a.i.g.a(:36)
        at d.k.a.i.g.doInBackground(:17)
        at android.os.AsyncTask$2.call(AsyncTask.java:295)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at java.lang.Thread.run(Thread.java:818) 
     Caused by: java.lang.IllegalStateException: Could not read resource entities-xhtml.properties. Make sure you copy resources for l.b.g.i
        at l.b.g.i.b(:301)
        at l.b.g.i.a(:25)
        at l.b.g.i$b.<init>(:53)
        at l.b.g.i$b.<clinit>(:34)
        at l.b.g.f$a.<init>(:372) 
        at l.b.g.f.<init>(:19) 
        at l.b.h.m.a(:32) 
        at l.b.h.m.b(:42) 
        at l.b.h.b.b(:56) 
        at l.b.h.g.a(:32) 
        at l.b.f.a.a(:135) 
        at l.b.f.b$d.f(:747) 
        at l.b.f.b.b(:250) 
        at d.k.a.i.g.a(:36) 
        at d.k.a.i.g.doInBackground(:17) 
        at android.os.AsyncTask$2.call(AsyncTask.java:295) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at java.lang.Thread.run(Thread.java:818) 
02-10 15:19:58.687 17254-20516/? E/cjle: *~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*
        Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
02-10 15:20:25.416 17254-28037/? E/WakeLock: GCM_HB_ALARM release without a matched acquire!

请告诉我我的代码出了什么问题

谢谢

1 个答案:

答案 0 :(得分:1)

错误堆栈表明: 原因:java.lang.IllegalStateException:无法读取资源实体-xhtml.properties。确保为l.b.g.i复制资源

我认为这是因为ProGuard排除了资源/类l.b.g.i。您可能想使用mappings.txt文件(包含实际的类/方法名称与proGuard生成的随机名称之间的映射)来解码实际的资源名称,然后强制Proguard保留它,例如以下示例https://stackoverflow.com/a/5866755/1992013这有帮助!