问题描述:
上午还好好的,下午写了几行代码,一运行App就闪退,
java.lang.VerifyError: Verifier rejected class xxx.HelpUtils: void com.yxg.worker.utils.HelpUtils.initPhone(android.content.Context, android.widget.TextView, com.yxg.worker.model.OrderModel, com.yxg.worker.model.UserModel, int) failed to verify: void com.xxx.utils.HelpUtils.initPhone(android.content.Context, android.widget.TextView, com.yxg.worker.model.OrderModel, com.xxx.model.UserModel, int): [0x6C] register v3 has type Reference: android.content.Context but expected Reference: com.xxx.utils.HelpUtils (declaration of 'com.xxx.utils.HelpUtils' appears in /data/app/com.xxx-LES49vYuzlJjjnHRzh_0tg==/base.apk!classes17.dex)
at com.xxx.utils.HelpUtils.needSplash(HelpUtils.java:230)
at com.xxx.ui.LaunchActivity.startMain(LaunchActivity.java:107)
at com.xxx.ui.LaunchActivity.checkBasePermission(LaunchActivity.java:122)
at com.xxx.ui.LaunchActivity.onCreate(LaunchActivity.java:55)
at android.app.Activity.performCreate(Activity.java:7986)
at android.app.Activity.performCreate(Activity.java:7975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3482)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3661)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:140)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:100)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2232)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:238)
at android.app.ActivityThread.main(ActivityThread.java:7820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
就增加了几行不可能报错的代码,一直闪退,还原版本,就正常了,最终经过分析得出……
原因分析:
一个类中代码行数超出限制行数,具体多少行待确定,超过3500行(接手外包代码)
如果类过大,java类加载会耗时并且占用内存大。容易引起内存回收。java类加载会耗时并且占用内存大。容易引起内存回收。
解决方案:
代码行数应该尽可能的少,这样能减少java类的加载时间,减少内存频繁占用和回收。
所以,遇到行数过多的类,重构吧……