问题描述
我正在使用Android Studio开发应用程序,当我从 debug 切换到 release 构建变体时,它开始崩溃.在调试时,它什么也没有发生.真正的问题是,由于每个引用都被重命名,所以我找不到真正的错误在哪里.
I'm developing an app using Android Studio, and when I switched from debug to release build variant, it began to crash. While on debug it doesn't happen anything at all. The real problem is that I can't find where is the true error, as every reference is renamed.
您是否遇到过这样的错误,仅在版本上才发生?
Have you faced an error like this, that has happened only on release?
打印纸叠是这样的:
04-11 08:28:42.756 5997-5997/com.korcholis.clothio E/ActivityThread﹕ Failed to inflate
android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at android.app.Activity.setContentView(Activity.java:1906)
at android.support.v7.a.g.a(Unknown Source)
at android.support.v7.a.n.a(Unknown Source)
at android.support.v7.a.g.setContentView(Unknown Source)
at com.korcholis.clothio.SampleListActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5303)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Could not find constructor that hast just a (Context) argument for helper class class com.korcholis.clothio.b.c
at com.a.a.a.a.a.c(Unknown Source)
at com.a.a.a.a.a.b(Unknown Source)
at com.a.a.a.a.a.a(Unknown Source)
at com.korcholis.clothio.fragments.SampleListFragment.a(Unknown Source)
at android.support.v4.app.Fragment.i(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.ae.b(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.w.onCreateView(Unknown Source)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at android.app.Activity.setContentView(Activity.java:1906)
at android.support.v7.a.g.a(Unknown Source)
at android.support.v7.a.n.a(Unknown Source)
at android.support.v7.a.g.setContentView(Unknown Source)
at com.korcholis.clothio.SampleListActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5303)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context]
at java.lang.Class.getConstructorOrMethod(Class.java:423)
at java.lang.Class.getConstructor(Class.java:397)
at com.a.a.a.a.a.c(Unknown Source)
at com.a.a.a.a.a.b(Unknown Source)
at com.a.a.a.a.a.a(Unknown Source)
at com.korcholis.clothio.fragments.SampleListFragment.a(Unknown Source)
at android.support.v4.app.Fragment.i(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.ae.b(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.w.onCreateView(Unknown Source)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at android.app.Activity.setContentView(Activity.java:1906)
at android.support.v7.a.g.a(Unknown Source)
at android.support.v7.a.n.a(Unknown Source)
at android.support.v7.a.g.setContentView(Unknown Source)
at com.korcholis.clothio.SampleListActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5303)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
04-11 08:28:42.756 5997-5997/com.korcholis.clothio D/AndroidRuntime﹕ Shutting down VM
04-11 08:28:42.756 5997-5997/com.korcholis.clothio W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41902700)
04-11 08:28:42.756 5997-5997/com.korcholis.clothio E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.korcholis.clothio/com.korcholis.clothio.SampleListActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5303)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at android.app.Activity.setContentView(Activity.java:1906)
at android.support.v7.a.g.a(Unknown Source)
at android.support.v7.a.n.a(Unknown Source)
at android.support.v7.a.g.setContentView(Unknown Source)
at com.korcholis.clothio.SampleListActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5303)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Could not find constructor that hast just a (Context) argument for helper class class com.korcholis.clothio.b.c
at com.a.a.a.a.a.c(Unknown Source)
at com.a.a.a.a.a.b(Unknown Source)
at com.a.a.a.a.a.a(Unknown Source)
at com.korcholis.clothio.fragments.SampleListFragment.a(Unknown Source)
at android.support.v4.app.Fragment.i(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.ae.b(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.w.onCreateView(Unknown Source)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at android.app.Activity.setContentView(Activity.java:1906)
at android.support.v7.a.g.a(Unknown Source)
at android.support.v7.a.n.a(Unknown Source)
at android.support.v7.a.g.setContentView(Unknown Source)
at com.korcholis.clothio.SampleListActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5303)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context]
at java.lang.Class.getConstructorOrMethod(Class.java:423)
at java.lang.Class.getConstructor(Class.java:397)
at com.a.a.a.a.a.c(Unknown Source)
at com.a.a.a.a.a.b(Unknown Source)
at com.a.a.a.a.a.a(Unknown Source)
at com.korcholis.clothio.fragments.SampleListFragment.a(Unknown Source)
at android.support.v4.app.Fragment.i(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.ae.b(Unknown Source)
at android.support.v4.app.ae.a(Unknown Source)
at android.support.v4.app.w.onCreateView(Unknown Source)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at android.app.Activity.setContentView(Activity.java:1906)
at android.support.v7.a.g.a(Unknown Source)
at android.support.v7.a.n.a(Unknown Source)
at android.support.v7.a.g.setContentView(Unknown Source)
at com.korcholis.clothio.SampleListActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5303)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
谢谢你们
正如AesSedai101所说,这是Proguard和我正在使用的东西之间的一个问题:Ormlite.因此,我将添加对我有用的标记和一个proguard文件:
So as AesSedai101 stated, it was a matter between Proguard and something I am using: Ormlite. So I'll add the tag and a proguard file that worked to me:
-keepattributes Signature
-keep class com.korcholis.clothio.data.** { *; }
-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }
用存储数据库模型的软件包替换com.korcholis.clothio.data.**
,但不要忘记最后的.**
Replace com.korcholis.clothio.data.**
with the package where you store your database models, but don't forget the final .**
推荐答案
好像Proguard正在从您的一个类中删除构造函数.请确保添加手册中指定的Proguard配置.如果未添加此选项,则Proguard将删除所有未使用的代码,其中包括诸如Activity构造函数之类的内容.
Looks like Proguard is removing a constructor from one of your classes. Be sure to add the Proguard config as specified in the manual. If this is not added, Proguard will remove all unused code, which includes things like Activity constructors.
这篇关于发布时的应用崩溃,而调试时不崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!