我正在尝试将Proguard应用到我的发布应用程序,但到目前为止,我一直在收到错误。调试构建完美:
04-06 20:25:17.689 544-544/com.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 544
java.lang.AssertionError
at com.google.b.b.a.r.<init>(Unknown Source)
at com.google.b.b.a.q$19.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k$1.<init>(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.google.b.b.a.b.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k$1.<init>(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.b.a.k.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.google.b.f.a(Unknown Source)
at com.a.a.a.a(Unknown Source)
at com.myapp.activities.bj.onResume(Unknown Source)
at android.support.v4.app.Fragment.performResume(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.ae.f(Unknown Source)
at android.support.v4.app.ae.g(Unknown Source)
at android.support.v4.app.ae.b(Unknown Source)
at android.support.v4.app.ah.finishUpdate(Unknown Source)
at android.support.v4.view.ViewPager.populate(Unknown Source)
at android.support.v4.view.ViewPager.populate(Unknown Source)
at android.support.v4.view.ViewPager.onMeasure(Unknown Source)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(Unknown Source)
at android.support.design.widget.CoordinatorLayout.onMeasure(Unknown Source)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.support.v7.widget.ContentFrameLayout.onMeasure(Unknown Source)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)
at android.view.View.measure(View.java:17547)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2015)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1173)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1379)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(
我已将以下规则添加到我的proguard-rules.pro文件中:
#for support library
# support design
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
#Support v7
# Hide warnings about references to newer platforms in the library
-dontwarn android.support.v7.**
# don't process support library
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
#Support v4
# Hide warnings about references to newer platforms in the library
-dontwarn android.support.v4.**
# don't process support library
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }
我不知道该怎么做 - 错误描述并不是真的告诉我所以我不知道assertionError来自哪里。
有谁知道如何解决这个问题?
答案 0 :(得分:0)
在proguard.txt文件中添加这些行应该有帮助。
ALTER TABLE professor
ADD
("Total Budget" varchar2(10),
"Lowest Salary" varchar2(6),
"Highest Salary" varchar2(7)
);
INSERT INTO professor ("Total Budget")
SELECT SUM(pr_salary) FROM professor
WHERE professor.pr_salary > 80000 AND professor.pr_title='Professor';
INSERT INTO professor ("Lowest Salary")
SELECT MIN(pr_salary) FROM professor
WHERE professor.pr_salary > 80000 AND professor.pr_title='Professor';
INSERT INTO professor ("Highest Salary")
SELECT MAX(pr_salary) FROM professor
WHERE professor.pr_salary > 80000 AND professor.pr_title='Professor';
答案 1 :(得分:0)
所以我对Proguard很陌生,但在调查之后想出了答案。我读了这个网站,你可以对堆栈跟踪进行去混淆,因为堆栈跟踪被混淆了 - 这就是你看到a.a.a或b.b.b等的原因:https://developer.android.com/tools/help/proguard.html
对于mac,您需要导航到此文件夹:
sdk/tools/proguard/bin/
您将在其中看到retrace.sh脚本。您现在需要在此处找到文件夹中的mapping.txt文件:
app/build/outputs/mapping/release/
将其复制到sh所在的bin文件夹中。然后,您需要复制要对其进行去混淆的堆栈跟踪部分,并将其粘贴到文本文件中并将其放入bin文件夹中。
使用以下命令在终端中进行反模糊处理:
sh retrace.sh -verbose mapping.txt obfuscated_trace.txt > deobfuscated_trace.txt
打开deobfuscated_trace.txt
,您会发现错误实际上指向GSON。我通过导入GSON的proguard规则来修复它。
要检查proguard是否正确运行,您将看到日志现在如下所示:
04-06 21:20:15.453 6853-6853/com.myapp E/y: last vis 3
04-06 21:20:15.463 6853-6853/com.myapp E/y: last vis 3
04-06 21:20:15.480 6853-6853/com.myapp E/y: last vis 3
你可以看到类名现在已被混淆,以前它应该是:
04-06 21:20:15.453 6853-6853/com.myapp E/MyFragment: last vis 3