Usando Navigation Comopent con el contenedor FragmentContainerView en versión release de la app se puede recibir el siguiente error
Error Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists
Log error entero:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.webserveis.mqtthomepresence/com.webserveis.mqtthomepresence.MainActivity}: android.view.InflateException: Binary XML file line #32 in
Caused by: android.view.InflateException: Binary XML file line #32 in com.webserveis.mqtthomepresence:layout/activity_main: Binary XML file line #11 in com.webserveis.mqtthomepresence:layout/content_main: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #11 in com.webserveis.mqtthomepresence:layout/content_main: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: androidx.fragment.app.Fragment$e: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists
Caused by: java.lang.ClassNotFoundException: androidx.navigation.fragment.NavHostFragment
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.navigation.fragment.NavHostFragment" on path: DexPathList[[zip file "/data/app/com.webserveis.mqtthomepresence-vwfs3OIb6HVkt8eRncOp9g==/base.apk"],nativeLibraryDirectories=[/data/app/com.webserveis.mqtthomepresence-vwfs3OIb6HVkt8eRncOp9g==/lib/arm64, /system/lib64, /system/product/lib64]]
Buscando por SO, eso suele pasar cuando se implementa ofuscar el código usando minifyEnabled = true
Solución
La solución es añadir en proguard una directiva keep en el archivo proguard-rules.pro
-keep class * extends androidx.fragment.app.Fragment{}