APK is not working Error inflating NavigationView

1

This is the log:

2021-04-20 14:39:24.496 1246-3646/? E/Parcel: Class not found when unmarshalling: aroo
    java.lang.ClassNotFoundException: aroo
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at android.os.Parcel.readParcelableCreator(Parcel.java:3031)
        at android.os.Parcel.readParcelable(Parcel.java:2981)
        at android.os.Parcel.readValue(Parcel.java:2883)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3261)
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
        at android.os.BaseBundle.unparcel(BaseBundle.java:236)
        at android.os.BaseBundle.getString(BaseBundle.java:1160)
        at android.content.Intent.getStringExtra(Intent.java:8552)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:847)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:732)
        at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:2074)
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:646)
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1717)
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1613)
        at com.android.server.wm.ActivityTaskManagerService.startActivity(ActivityTaskManagerService.java:1566)
        at android.app.IActivityTaskManager$Stub.onTransact(IActivityTaskManager.java:1754)
        at android.os.Binder.execTransactInternal(Binder.java:1056)
        at android.os.Binder.execTransact(Binder.java:1029)
     Caused by: java.lang.ClassNotFoundException: aroo
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:454) 
        at android.os.Parcel.readParcelableCreator(Parcel.java:3031) 
        at android.os.Parcel.readParcelable(Parcel.java:2981) 
        at android.os.Parcel.readValue(Parcel.java:2883) 
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3261) 
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292) 
        at android.os.BaseBundle.unparcel(BaseBundle.java:236) 
        at android.os.BaseBundle.getString(BaseBundle.java:1160) 
        at android.content.Intent.getStringExtra(Intent.java:8552) 
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:847) 
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:732) 
        at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:2074) 
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:646) 
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1717) 
        at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1613) 
        at com.android.server.wm.ActivityTaskManagerService.startActivity(ActivityTaskManagerService.java:1566) 
        at android.app.IActivityTaskManager$Stub.onTransact(IActivityTaskManager.java:1754) 
        at android.os.Binder.execTransactInternal(Binder.java:1056) 
        at android.os.Binder.execTransact(Binder.java:1029) 
2021-04-20 14:39:24.547 1246-1492/? E/PkgPredictorService-Collector: record changed bt=0  wifi=1 screen=0
2021-04-20 14:39:24.616 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, errorCode=3
2021-04-20 14:39:24.616 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, skipClientNotification=false
2021-04-20 14:39:24.617 696-12098/? E/Camera3-OutputStream: returnBufferCheckedLocked: A frame is dropped for stream 0 due to buffer error.
2021-04-20 14:39:24.627 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, errorCode=3
2021-04-20 14:39:24.627 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, skipClientNotification=false
2021-04-20 14:39:24.627 696-12098/? E/Camera3-OutputStream: returnBufferCheckedLocked: A frame is dropped for stream 0 due to buffer error.
2021-04-20 14:39:24.628 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, errorCode=3
2021-04-20 14:39:24.628 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, skipClientNotification=false
2021-04-20 14:39:24.628 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, errorCode=3
2021-04-20 14:39:24.628 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, skipClientNotification=false
2021-04-20 14:39:24.628 696-12098/? E/Camera3-OutputStream: returnBufferCheckedLocked: A frame is dropped for stream 0 due to buffer error.
2021-04-20 14:39:24.629 696-12098/? E/Camera3-OutputStream: returnBufferCheckedLocked: A frame is dropped for stream 0 due to buffer error.
2021-04-20 14:39:24.630 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, errorCode=3
2021-04-20 14:39:24.630 696-12098/? E/CameraDeviceClient: notifyError: pid=29856, skipClientNotification=false
2021-04-20 14:39:24.631 696-12098/? E/Camera3-OutputStream: returnBufferCheckedLocked: A frame is dropped for stream 0 due to buffer error.
2021-04-20 14:39:24.633 696-21635/? E/CameraDeviceClient: Disconnect from CameraDeviceClient
2021-04-20 14:39:24.633 696-21635/? E/Camera2-FrameProcessorBase: removeListener: 
2021-04-20 14:39:24.647 602-16625/? E/BWC: MTK_IOC_SMI_BWC_INFO_GET failed.:Not a typewriter
2021-04-20 14:39:24.649 602-16625/? E/BWC: MTK_IOC_SMI_BWC_INFO_SET failed.:Not a typewriter
2021-04-20 14:39:24.657 1246-1829/? E/SensorService: BigData:Pakage) 4 already enabled. 
2021-04-20 14:39:24.663 26398-26398/? E/DecorView: mWindow.mActivityCurrentConfig is null
2021-04-20 14:39:24.739 2530-2530/? E/pageboostd: Received HALT command code 2
2021-04-20 14:39:24.843 1246-1267/? E/Watchdog: !@Sync: 16358 heap: 88 / 108 [2021-04-20 14:39:24.843] sdogWay: None
2021-04-20 14:39:24.879 597-641/? E/libPowerHal: perfLockRel handle:242419
2021-04-20 14:39:24.885 597-641/? E/RilUtility: notify_rild_opt_info socket error
2021-04-20 14:39:24.887 597-641/? E/RilUtility: notify_rild_opt_info socket error
2021-04-20 14:39:24.889 597-641/? E/libPowerHal: perfLockRel handle:242420
2021-04-20 14:39:25.303 597-641/? E/RilUtility: notify_rild_opt_info socket error
2021-04-20 14:39:25.304 597-641/? E/RilUtility: notify_rild_opt_info socket error
2021-04-20 14:39:25.305 597-641/? E/libPowerHal: perfLockRel handle:242423
2021-04-20 14:39:25.348 1246-1265/? E/system_server: Invalid ID 0x00000000.
2021-04-20 14:39:25.384 1246-1265/? E/DecorView: mWindow.mActivityCurrentConfig is null
2021-04-20 14:39:25.465 19736-19736/? E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.mainPageShop}: android.view.InflateException: Binary XML file line #543 in com.example:layout/main_page_normal: Binary XML file line #543 in com.example:layout/main_page_normal: Error inflating class com.google.android.material.navigation.NavigationView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3654)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
     Caused by: android.view.InflateException: Binary XML file line #543 in com.example:layout/main_page_normal: Binary XML file line #543 in com.example:layout/main_page_normal: Error inflating class com.google.android.material.navigation.NavigationView
     Caused by: android.view.InflateException: Binary XML file line #543 in com.example:layout/main_page_normal: Error inflating class com.google.android.material.navigation.NavigationView
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:854)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at androidx.appcompat.app.x.c(Unknown Source:23)
        at androidx.appcompat.app.m.setContentView(Unknown Source:4)
        at com.example.mainPageShop.onCreate(Unknown Source:6)
        at android.app.Activity.performCreate(Activity.java:7963)
        at android.app.Activity.performCreate(Activity.java:7952)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3629)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
     Caused by: java.lang.NoSuchMethodError: No static method asAttributeSet(Lj/d/a/a;)Landroid/util/AttributeSet; in class Landroid/util/Xml; or its super classes (declaration of 'android.util.Xml' appears in /system/framework/framework.jar!classes3.dex)
2021-04-20 14:39:25.465 19736-19736/? E/AndroidRuntime:     at b.a.d.g.inflate(Unknown Source:21)
        at com.google.android.material.navigation.NavigationView.c(Unknown Source:12)
        at com.google.android.material.navigation.NavigationView.<init>(Unknown Source:255)
        at com.google.android.material.navigation.NavigationView.<init>(Unknown Source:2)
            ... 28 more

Here is the main page that causing the error:

 <androidx.drawerlayout.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_layout21"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    tools:openDrawer="end" >


    <com.google.android.material.navigation.NavigationView

        android:id="@+id/main_drawer"
        android:layout_width="230dp"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:background="@color/dark_gray"
        app:theme="@style/navigationTheme"
        app:itemTextColor="@color/white"
        app:menu="@menu/menu_drawer"
        app:headerLayout="@layout/header_layout"
        android:layoutDirection="rtl">

    </com.google.android.material.navigation.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>






**build.gradle :**

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    useLibrary  'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.example"
        minSdkVersion 24
        targetSdkVersion 28
        multiDexEnabled true

    }


    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }

    lintOptions {
        disable "ResourceType"
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
        javaMaxHeapSize "2g"
    }
}

ext {
    googlePlayServicesVersion = "4.1.0"
}


dependencies {
    implementation files('libs/icu4j-4_4_2_2.jar')
    implementation files('libs/jsoup-1.6.3.jar')
    implementation files('libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar')
    implementation files('libs/zip4j_1.2.6.jar')

    implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
        transitive = true;
    }

    implementation 'com.facebook.android:facebook-android-sdk:4.38.1'
    // Google
    implementation 'com.google.android.gms:play-services-auth:16.0.1'

    implementation'com.google.firebase:firebase-auth:16.1.0'

    // Firebase
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.google.firebase:firebase-core:16.0.3'


    //implementation 'com.google.android.gms:play-services-ads:17.2.1'

    implementation project(':pdflibrary')
    implementation 'androidx.core:core:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.browser:browser:1.0.0'

    implementation'junit:junit:4.12'

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.github.jd-alexander:LikeButton:0.2.3'
    implementation 'com.google.android.gms:play-services-flags:16.0.1'
    //implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.mikepenz:iconics-core:2.9.1@aar'
    implementation 'com.mikepenz:community-material-typeface:1.3.41.1@aar'

    implementation 'com.google.code.gson:gson:2.6.1'
    implementation 'com.android.volley:volley:1.1.1'

    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'

    implementation 'com.squareup.retrofit:retrofit:1.9.0'
    implementation 'com.squareup.okhttp:okhttp:2.7.2'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    implementation 'com.wealdtech.hawk:hawk-core:1.2.0'

    implementation 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
    implementation 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    implementation 'org.apache.commons:commons-lang3:3.5'

    implementation 'com.mikhaellopez:circularimageview:4.2.0'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation "androidx.constraintlayout:constraintlayout:2.0.4"

    implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:3.0.3'
    implementation 'com.diegodobelo.expandingview:expanding-view:0.9.4'
    implementation 'com.facebook.shimmer:shimmer:0.1.0@aar'



    implementation 'com.google.android.material:material:1.0.0'

    
    implementation 'androidx.navigation:navigation-fragment-ktx:2.2.0-rc03'
    implementation 'androidx.navigation:navigation-ui-ktx:2.2.0-rc03'

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '25.3.0'
                }
            }
        }
    }

}

I search this error before and tried a lot of solutions that didn't work the project runs just fine from android studio but the apk is always crashing with the same error I don't use files from drawable-24 And I tried the app:backgroundTint for NavigationView and didn't work

java
android
asked on Stack Overflow Apr 20, 2021 by M.J

1 Answer

1

I think I know what the issue is. For some reason, your proguard obfuscates android utility classes, which causes that error to happen.

Here is where the error actually occurs (this bit is called from NavigationView as I checked the source code of it, and it's called while inflating the menu):

     /**
     * Inflate a menu hierarchy from the specified XML resource. Throws
     * {@link InflateException} if there is an error.
     *
     * @param menuRes Resource ID for an XML layout resource to load (e.g.,
     *            <code>R.menu.main_activity</code>)
     * @param menu The Menu to inflate into. The items and submenus will be
     *            added to this Menu.
     */
    public void inflate(@MenuRes int menuRes, Menu menu) {
        XmlResourceParser parser = null;
        try {
            parser = mContext.getResources().getLayout(menuRes);
            AttributeSet attrs = Xml.asAttributeSet(parser); // This is the line

            parseMenu(parser, attrs, menu);
        } catch (XmlPullParserException e) {
            throw new InflateException("Error inflating menu XML", e);
        } catch (IOException e) {
            throw new InflateException("Error inflating menu XML", e);
        } finally {
            if (parser != null) parser.close();
        }
    }

The Xml class comes from the package android.util and it has nothing to do with the project itself (I mean, it's a framework class.)

To prevent such errors, you can add this line for the proguard file.

-keep class android.util.** { *; }

If this doesn't work, try changing it to this:

-keep class android.** { *; }

The rules tell the compiler to keep classes that start with the package "android" which usually contain framework classes.

answered on Stack Overflow Apr 30, 2021 by Furkan Yurdakul • edited Apr 30, 2021 by Furkan Yurdakul

User contributions licensed under CC BY-SA 3.0