Issue
I have issue with androidx.navigation last updates
I have noticed that after fresh update (2.2.2) crashed if build is RELEASE with error like
Caused by: android.view.InflateException: Binary XML file line #12 in
com.somedomain.android:layout/activity_main: Binary XML file line #12 in
com.somedomain.android:layout/activity_main: Error inflating class
androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #12 in
com.somedomain.android:layout/activity_main: Error inflating class
androidx.fragment.app.FragmentContainerView
androidx.fragment.app.Fragment$e: Unable to instantiate fragment
androidx.navigation.fragment.NavHostFragment: make sure class name exists
I am using:
ext.versions = [
...
nav_version : '2.2.2',
]
ext.libs = [
...
nav_fragment : "androidx.navigation:navigation-fragment-ktx:$versions.nav_version",
nav_ui : "androidx.navigation:navigation-ui-ktx:$versions.nav_version",
]
In App gradle
...
buildTypes {
debug {
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
ext.enableCrashlytics = false
signingConfig signingConfigs.debug
debuggable = true
}
release {
manifestPlaceholders = [crashlyticsCollectionEnabled: "true"]
ext.enableCrashlytics = true
minifyEnabled true
shrinkResources true
debuggable = false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
...
implementation libs.nav_fragment
implementation libs.nav_ui
Navigation host in activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout 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"
tools:context=".MainActivity">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/main_nav_host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/main_navigation" />
</FrameLayout>
</layout>
Language: Kotlin
Has anybody face with the problem like this?
Note: With version 2.2.1 everything was OK. Debug version build also is OK
I think the issue related to this change. according to official Android nav components release notes
The navigation-common-ktx ProGuard rules now correctly only keep the NavArgs classes that are used rather than all NavArgs instances. This was previously released in Navigation 2.3.0-alpha03. (b/150213558
Solution
Damn. I found.
It's need to add -keep class androidx.navigation.fragment.NavHostFragment
in the proguard-rules.pro file.
Answered By - Narek Hayrapetyan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.