简体   繁体   English

应用程序从签名的 APK 而不是 Android Studio 崩溃

[英]App crashes from signed APK but not Android studio

My application runs just fine when installed from Android studio but as soon as I install and signed APK to any device the app will not run.从 Android Studio 安装时,我的应用程序运行良好,但一旦我将 APK 安装并签名到任何设备,该应用程序将无法运行。 Below is a crash dump from a friends device that was provided from the Google Play Developer Console.下面是从 Google Play 开发者控制台提供的朋友设备的故障转储。 Obviously it has something to do with the layout but I'm not sure what is causing it in the release build but not while testing.显然它与布局有关,但我不确定是什么导致它在发布版本中但不是在测试时。 No Errors show up when I'm testing it on my device and there are no errors in android studio.当我在我的设备上测试它并且 android studio 中没有错误时,没有出现错误。 I'm fairly new to developing so I am not sure what to do.我对开发还很陌生,所以我不知道该怎么做。 Any help or suggestions would be greatly appreciated.任何帮助或建议将不胜感激。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.j.a.p/com.j.a.p.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
        at android.app.ActivityThread.access$1100(ActivityThread.java:221)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:158)
        at android.app.ActivityThread.main(ActivityThread.java:7224)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
        at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
        at android.support.v7.a.w.a(SourceFile:257)
        at android.support.v7.a.p.setContentView(SourceFile:109)
        at com.j.a.p.MainActivity.onCreate(SourceFile:31)
        at android.app.Activity.performCreate(Activity.java:6876)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
        ... 9 more
    Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
        at android.view.LayoutInflater.createView(LayoutInflater.java:657)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
        ... 17 more
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at android.view.LayoutInflater.createView(LayoutInflater.java:631)
        ... 22 more
    Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.design.internal.NavigationMenuView
        at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
        at android.support.design.internal.c.a(SourceFile:97)
        at android.support.design.widget.NavigationView.<init>(SourceFile:165)
        at android.support.design.widget.NavigationView.<init>(SourceFile:94)
        ... 24 more
    Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.internal.NavigationMenuView
        at android.view.LayoutInflater.createView(LayoutInflater.java:657)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
        ... 28 more
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at android.view.LayoutInflater.createView(LayoutInflater.java:631)
        ... 31 more
    Caused by: java.lang.IllegalStateException: Binary XML file line #17: Error creating LayoutManager android.support.v7.widget.LinearLayoutManager
        at android.support.v7.widget.RecyclerView.a(SourceFile:540)
        at android.support.v7.widget.RecyclerView.<init>(SourceFile:485)
        at android.support.design.internal.NavigationMenuView.<init>(SourceFile:39)
        at android.support.design.internal.NavigationMenuView.<init>(SourceFile:35)
        ... 33 more
    Caused by: java.lang.NoSuchMethodException: <init> []
        at java.lang.Class.getConstructor(Class.java:528)
        at java.lang.Class.getConstructor(Class.java:492)
        at android.support.v7.widget.RecyclerView.a(SourceFile:537)
        ... 36 more
    Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet, int, int]
        at java.lang.Class.getConstructor(Class.java:528)
        at java.lang.Class.getConstructor(Class.java:492)
        at android.support.v7.widget.RecyclerView.a(SourceFile:532)
        ... 36 more

Try deleting proguard directory in your project On any proguard files such as proguard-android.txt or proguard-rules.pro.尝试删除项目中的 proguard 目录 在任何 proguard 文件上,例如 proguard-android.txt 或 proguard-rules.pro。

2nd option - try in your build.gradle file第二个选项 - 在你的 build.gradle 文件中尝试

 buildTypes {

        debug {
            minifyEnabled false

        }
        release {
            minifyEnabled false

        }
    }

Use any of the options or a combination of both使用任何选项或两者的组合

如果你添加了像 glide 这样需要在 proguard 中提及的库,你应该将需要的行添加到你的 proguard-rules.pro

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM