Android App suddenly crashes when compiling in Release Mode and running on connected phone on Viisual Studio 2022

Riffy 276 Reputation points


My App was working fine when build to release mode, and both when downloading from Google play store or from a Android device connected to computer.

I am using Xamarin VS Studio 2022 and C#.

But it has suddenly started failing.

I get the following error among others:

Time Device Name Type PID Tag Message
04-30 15:15:19.075 Samsung SM-J320FN Error 19103 AndroidRuntime Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.appcompat.widget.FitWindowsFrameLayout" on path: DexPathList[[zip file "/data/app/com.proj.proj-2/base.apk", zip file "/data/app/com.proj.proj-2/split_config.armeabi_v7a.apk", zip file "/data/app/com.asirkl.irkl-2/split_config.en.apk", zip file "/data/app/com.asirkl.irkl-2/split_config.xhdpi.apk"],nativeLibraryDirectories=[/data/app/com.proj.proj-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at android.view.LayoutInflater.createView(
at android.view.LayoutInflater.createViewFromTag(
... 24 more
Suppressed: Zip archive '/data/app/com.proj.proj-2/split_config.armeabi_v7a.apk' doesn't contain classes.dex (error msg: Entry not found)
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(
at dalvik.system.DexFile.<init>(
at dalvik.system.DexFile.<init>(
at dalvik.system.DexPathList.loadDexFile(
at dalvik.system.DexPathList.makeDexElements(
at dalvik.system.DexPathList.<init>(
at dalvik.system.BaseDexClassLoader.<init>(
at dalvik.system.PathClassLoader.<init>(


Time Device Name Type PID Tag Message
04-30 15:15:19.075 Samsung SM-J320FN Error 19103 AndroidRuntime java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asirkl.irkl/crc64d8b4ff5105917ffe.MainActivity}: android.view.InflateException: Binary XML file line #23: Error inflating class androidx.appcompat.widget.FitWindowsFrameLayout
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(

Can someone help me resolve this error.

The App works fine in Debug mode.


A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,323 questions
0 comments No comments
{count} vote

11 answers

Sort by: Most helpful
  1. Graham McKechnie 321 Reputation points

    AndroidRuntime Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.appcompat.widget.FitWindowsFrameLayout"

    You need to add a proguard.cfg to your app. Make sure in Properties of the proguard.cfg file that you set Build Action to ProguardConfiguration.
    The exception is telling you that r8 is removing that class.
    So you need to add a keep rule like the following in a proguard.cfg.

    -keep class androidx.appcompat.widget.FitWindowsFrameLayout

    Fix that one and you may well find others. Keep adding the missing classes that result in ClassNotFoundExceptions until it doesn't crash.

    You can check each one by checking what is already included by checking the proguard folder in C:\Users\<yourusername>.nuget\packages\xamarin.androidx.appcompat\\proguard

    Just make sure that you are checking the correct folder for the same version as what you are using in your app.

    The quick fix (not recommended) is to turn off r8.

    Add the following to the top of your proguard.cfg before any of your keep rules.

    -printconfiguration config_your_appname.txt
    -printseeds seeds.txt
    -printusage usage.txt
    #usage.txt - this file contains the code that was removed from the apk
    #seeds.txt - this file has a list of classes and class members which were not obfuscated
    #mappings.txt - this file provides the translation between the original and the obfuscated classes, methods, field names. Not applicable to xamarin, because we don't obfuscate. Required when uploading the aab to Google Play.

  2. Graham McKechnie 321 Reputation points


    All the contents of that particular proguard.txt file tell us is that you do need to create your own proguard.cfg in your project. By default that file is keeping the class androidx.appcompat.widget.SearchView, but there is no mention of FitWindowsFrameLayout. Therefore you have to create your own specific keep rules for FitWindowsFrameLayout for your app.

    From your comments, I gather you haven't done that.

    Add what I suggested, in my post with the additional line below and then rebuild and see if the crash is eliminated. Don't be surprised if there are more ClassNotFoundExceptions for other classes. However, you should expect that the FitWindowsFrameLayout ClassNotFoundException should be gone if you added the line below to your proguard cfg file.

    -keep class androidx.appcompat.widget.FitWindowsFrameLayout  

    If you search google for proguard/r8 you should find specific articles about using r8.

    If you are still having problems, please post the contents of your proguard.cfg. I forgot to add in my post that the proguard.cfg should be added to the root folder of your project and don't forget to change the BuildAction to ProguardConfiguration.

    Once you have it working you should be able to read the contents of both the seeds and usage txt files.

    I'd make the following suggestion to help save your sanity. Make sure as you are developing a particular feature in debug mode that when you are finished, always then do a full release build with dx/r8 enabled and link with SDK and Use Assemblies and package format as aab. That way you know about problems like this immediately. Trying to sort out release r8 issues when you are fully done at the end of the project can be a real pain. I had one recently that took me about a week to get sorted. See

  3. Graham McKechnie 321 Reputation points

    The error is telling what is wrong.

    My post stated r8 not proguard, so just change it to r8.

    You are calling the file proguard.txt, however in your Xamarin.Android project it should be proguard.cfg and the build action should be ProguardConfiguration. Once you have the proguard.cfg file in your project. Select it and then Right Click it. Select Properties, then beside Build Action use the drop-down to select ProguardConfiguration.

    Remove the following lines

    -keep class androidx.appcompat.widget.SearchView { <init>(...); }  
    -keepclassmembernames,allowobfuscation,allowshrinking class androidx.appcompat.widget.AppCompatTextViewAutoSizeHelper$Impl* {  
     -keep class androidx.appcompat.widget.FitWindowsFrameLayout  

    Note the {} brackets, you have FitWindowsFrameLayout inside the previous class which is wrong.

    Note you don't need to repeat a keep rule that is already in a particular proguard.txt file in the .nuget folder as it is automatically read.

    Could you also indicate what version of Xamarin.AndroidX.AppCompat you are using?

    Finally, just place on a new line.

    -keep class androidx.appcompat.widget.FitWindowsFrameLayout  

    Note you also have a non ideal release setting for the linker. You should be using SDK and User Assemblies to get the smallest apk.

  4. Graham McKechnie 321 Reputation points

    Understand, it is always a struggle when you are starting out. My advice would be to always build a release build when you finish a particular feature. Leaving it to when the debug build is finished and expecting it to be ok in a release build is not going to work, unless you are extremely lucky.

    Always make your final build of the day a release build with all the correct release settings, that will give you some idea of where it has gone wrong from the previous release build if it does crash.

    Since you are using an old version of AppCompat, I would recommend upgrading your all .nugets to the latest versions. Just take note of the existing version numbers, so you can revert if necessary. Same thing applies when new versions are released in the future, never upgrade without taking note of what combination of version(s) were working.

    Now the important part. Have you now built a successful Release build, with the suggestions from yesterday? Have you read up on the Xamarin.Android articles on dx/r8 I referred to earlier?

  5. Graham McKechnie 321 Reputation points


    There is nothing very helpful in that error. If this is a runtime error we would need to see more info. Is this a build error or a runtime error?

    If a runtime error. Then you need to work backwards to confirm what it is. Turn off r8 in the project, i.e. set it to the blank value in the IDE. Rebuild and confirm that it can run. If that doesn't help reset the linker to SDK assemblies only. You are aiming to get back to a configuration that doesn't crash. I'm assuming one of the changes will allow it to run crash-free.

    Let us know your results.

    If none of that helps then it is time to report on Xamarin.Android.

    If you want to share your project, you could always set it up on github.

    You can probably see more information about a runtime crash if you use the logger Tools/Android/Device Logger. I don't particularly like it but it does work. If you want a logger that has more functionality install Android Studio. If this is crashing at startup then the information to look for will be near the top of the output.

    When you google that error, it leads you to with a number of similar issues - worth looking at.