B类

时间:2018-04-22 16:42:57

标签: android class apk signed

在通过AndroidStudio构建我签名的应用时,我遇到了一个奇怪的问题。

该应用已成功生成,但当我想在智能手机上启动时,我收到以下错误:

FATAL EXCEPTION: main
Process: my.package, PID: 21935
java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package/gui.Main}: android.view.InflateException: Binary XML file line #58: Binary XML file line #58: Error inflating class Button
    at android.app.ActivityThread.perfor

mLaunchActivity(ActivityThread.java:2984)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
 Caused by: android.view.InflateException: Binary XML file line #58: Binary XML file line #58: Error inflating class Button
 Caused by: android.view.InflateException: Binary XML file line #58: Error inflating class Button
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ae.a()' on a null object reference
    at android.support.v7.widget.ag.setBackgroundDrawable(Unknown Source)
    at android.view.View.setBackground(View.java:19498)
    at android.view.View.<init>(View.java:4932)
    at android.widget.TextView.<init>(TextView.java:1041)
    at android.widget.Button.<init>(Button.java:113)
    at android.widget.Button.<init>(Button.java:106)
    at android.support.v7.widget.ag.<init>(Unknown Source)
    at android.support.v7.widget.ag.<init>(Unknown Source)
    at android.support.v7.a.au.a(Unknown Source)
    at android.support.v7.a.af.a(Unknown Source)
    at android.support.v4.g.ad.onCreateView(Unknown Source)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
    at android.preference.PreferenceFragment.onCreateView(PreferenceFragment.java:179)
    at android.app.Fragment.performCreateView(Fragment.java:2352)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
    at android.app.BackStackRecord.run(BackStackRecord.java:815)
    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1582)
    at android.app.FragmentController.execPendingActions(FragmentController.java:372)
    at android.app.Activity.performStart(Activity.java:6971)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2937)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

当我通过调试模式启动应用程序或构建调试APK文件时,它会正常启动。

我发现第58行的一个二进制XML文件中的按钮存在问题。 但在哪个文件?在Main类中,只有一个没有任何按钮的首选项文件......

为什么它在调试模式下工作?

有什么想法吗? 谢谢!

1 个答案:

答案 0 :(得分:0)

当我禁用proguard时,它可以工作! : - )

但是proguard有什么问题?

这是我的Grandle文件:

buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard.cfg'
    }

}

proguard.cfg:

-ignorewarnings