使用导航抽屉时的Java运行时异常 [英] Java runtime exception when using navigation drawer

查看:106
本文介绍了使用导航抽屉时的Java运行时异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行我的项目,但是在加载时崩溃.我这里有我的保护者,因为到目前为止,它一直是所有问题的根源,而我的错误仍在下面.

I am trying to run my project but it crashes upon load. I have my proguard here as it has been the source of all issues so far and my error below that.

我尝试过:

  • 重新安装android studio
  • 干净的构建
  • 重建项目
  • 删除对丢失类的已知引用

我的proguard文件如下所示:

My proguard file is as shown:

-dontwarn android.net.http.**
-dontwarn org.apache.http.**
-dontwarn org.apache.httpcomponents.**
-dontwarn org.apache.commons.codec.**
-dontwarn com.android.build.transform.api.**
-dontwarn org.apache.commons.io.**
-dontwarn org.apache.lang.**
-dontwarn org.apache.commons.**
-dontwarn org.bouncycastle.**
-dontwarn org.joda.**
-dontwarn au.com.bytcode.opencsv.**
-dontwarn java.beans.**
-dontwarn com.google.**
-dontwarn java.lang.invoke.**
-dontwarn com.playerize.**
-dontwarn com.parse.**
-dontwarn org.apache.lang.**
-dontwarn org.apache.commons.**
-dontwarn com.chartboost.**
-dontwarn dagger.**
-dontwarn com.supersonic.**
-dontwarn org.bouncycastle.**
-dontwarn android.webkit.JavascriptInterface

错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.intellidev.bitrichpro/com.intellidev.bitrichpro.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
11-03 15:28:45.678 6098-6098/? E/AndroidRuntime:     at com.intellidev.bitrichpro.MainActivity.onCreate(Unknown Source)
    enter code here

Activity_main.xml

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:fitsSystemWindows="true" tools:openDrawer="start">

    <include layout="@layout/app_bar_main" android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView android:id="@+id/nav_view"
        android:layout_width="wrap_content" android:layout_height="match_parent"
        android:layout_gravity="start" android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>

新错误:

Unable to start activity ComponentInfo{com.intellidev.bitrichpro/com.intellidev.bitrichpro.MainActivity}: java.lang.IllegalArgumentException: Default constructor for class com.b.oc is not accessible

推荐答案

请将以下内容添加到您的proguard文件中.

Please add the following to your proguard file.

# keep classes with the `View(Context, Attributes)` constructor
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

# keep classes with the `View(Context, Attributes, int)` constructor
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

# keep methods that accept a view as their argument.
# This would be the case if you set an onclick from an xml file
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

# keep all of the design library
-keep class android.support.design.** { *; }

# keep all android classes
-keep class android.** { *; }

# keep all class members, don't rename methods
-keepclassmembers class android.** { *; }
-dontobfuscate

这篇关于使用导航抽屉时的Java运行时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆