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

Riffy 276 Reputation points
2022-04-30T23:03:51.713+00:00

Hi

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(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:578)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
... 24 more
Suppressed: java.io.IOException: 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(DexFile.java:295)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:262)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:231)
at dalvik.system.DexPathList.<init>(DexPathList.java:109)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:120)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:45)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:419)
at android.app.Lo

AND:

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.app.ActivityThread.performLaunchActivity(ActivityThread.java:3150)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3260)
at android.app.ActivityThread.access$1000(ActivityThread.java:218)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1734)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6934)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Can someone help me resolve this error.

The App works fine in Debug mode.

Thanks

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

11 answers

Sort by: Most helpful
  1. Graham McKechnie 321 Reputation points
    2022-05-07T00:16:30.293+00:00

    @Riffy

    Your posts are becoming very difficult to follow because I can't always tell from the images where they are coming from. The images yesterday showed the 3 proguard files in your project - today they are gone.

    I can't tell from your images if you are showing all files or not. i.e. Solution property - toggle switch Show all Files. Is it on or off? Those 3 files should never have been in the project root folder. They are MSBuild generated files and normally would be found in the obj folder as in
    C:\ProjectsVS2022Preview\NavigationGraph2\obj\Release\120\proguard (substitute your folder names for mine) which they appear to do in your latest image.

    As you can see, the files, seeds, usage and mapping do not appear in the project folder when I do a build.

    That is understandable - they are not going to appear if r8 hasn't been run. The original error message, (I can't copy/paste from an image) so I'll summarize it here.

    <Error  
    Text= "r8.jar does not exist etc...."  
    />  
    

    The error message is suggesting that the r8.jar doesn't exist on your machine. The keyword there is AndroidR8JarPath. It would appear your VS2022 installation, doesn't know that path and therefore can't find r8.jar.

    How about doing a VS2022 repair, then delete both the bin and obj folders using windows explorer. Or alternatively, install the latest Preview version VS2020 17.2.0 P6.0. Repair would be the quickest, however, I prefer to work with the Preview versions!

    If none of that helps. Then start a new project - make sure it is just an android project (you don't need any cross-platform stuff to further complicate it). For example, use the NavDrawer template. Then build it in both debug and release and make sure it launches. Then, in release introduce r8 - just built an apk, you don't need an aab for this test. Add the proguard.cfg from yesterday and set ProguardConfiguration (note you have a few additional spaces in the front of some of the lines - though I doubt that would make any difference). If that works then there is nothing wrong with your installation. The r8 version of NavDrawer may not even crash after all this (hopefully it does so you get to practice adding keep rules). Anyway, that test shouldn't take you more than a few minutes.

    While you're doing this - make sure Diagnostic logging is on. Tools/Options/Projects and Solutions/Build and Run/ Both MSBuild options - set them to Diagnostic. That will give you a chance to search the build Output window for all occurrences of r8 to get a better understanding of how r8 works and to check the AndroidR8JarPath. If that is successful, then repeat with your real project.

    If you want to take this to email just let me know.

    0 comments No comments