Android Application crash on release mode when using linking or Use shared runtime is unchecked if Xamarin.Forms version is greater than 3.1.0.583944
Edit: I've enable ProGuard, unchecked shared runtime and set Linking to "Sdk Assemblies Only" on Debug configuration now app crashed on base.OnCreate(savedInstanceState);
where savedInstanceState
is null with error message Unhandled Exception: Java.Lang.RuntimeException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.v7.widget.FitWindowsFrameLayout
Application should not crash
Application crash on Splash screen on release mode with these warning
Severity Code Description Project File Line Suppression State
Warning Failed to read 'C:\Users\defaultuser\source\repos\Temp\Temp\Temp.Android\obj\Release\90\linksrc\FormsViewGroup.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. 0
Severity Code Description Project File Line Suppression State
Warning Failed to read 'C:\Users\defaultuser\source\repos\Temp\Temp\Temp.Android\obj\Release\90\android\assets\FormsViewGroup.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. 0
Severity Code Description Project File Line Suppression State
Warning Failed to read 'C:\Users\defaultuser\source\repos\Temp\Temp\Temp.Android\obj\Release\90\android\assets\Xamarin.Forms.Platform.Android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. 0
Severity Code Description Project File Line Suppression State
Warning Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly
at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching)
at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(Disposable1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) 0
Severity Code Description Project File Line Suppression State
Warning Failed to read 'C:\Users\defaultuser\source\repos\Temp\Temp\Temp.Android\obj\Release\90\linksrc\Xamarin.Forms.Platform.Android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. 0
Nuget Packages:
Affected Devices: All
I face this issue, any workaround yet?
@iswahyudhie Yes, just follow one of these Method
ProguardConfiguration
Proguard.cfg
with notepad or any text editor just don't create it with Visual Studio, make sure its encoding is just UTF-8
not anything else. (Important)Proguard.cfg
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class android.support.v7.widget.** { *; }
-dontwarn android.support.v7.widget.**
-keep class android.support.v4.widget.Space { *; }
-dontwarn android.support.v4.widget.Space
ProGuard.cfg
file and change its Build Action to ProguardConfiguration
Note: If you get java.exe exited with code 1 then your ProGuard.cfg
file is not UTF-8
or your forget to change its Build Action to ProguardConfiguration
hi Uzairali,
thanks for your reply,
unfortunately, your workaround does not work in my project, I realize even without pro guard checked this issue still occurs. only work if I set the linking to none but the warning still appears. at least the app can run normally. maybe in my case, it's not related with proguard enable.
@iswahyudhie As far as I know this issue is related to Linking. Proguard is just a configuration file for linking, it tells linker what not to skip so in your case you must be using some plugins which linker is striping. Try this maybe it might solve your problem
Xamarin Diagnostics output verbosity
to Detailed
Debug
mode, Open Android project's property
Android Options
and make sure Debug
configuration is selected, then disable Use Shared Runtime
, enable Enable ProGuard
and set linking to SKDs assemblies Only
.If its something like missing dll then add that in proguard configuration file
Hi Uzairali,
Apologies for the delay and thanks for your detail step. after doing that, it leads me to another error that reported in this link https://github.com/xamarin/xamarin-android/issues/2620
I do some extra step explained in that GitHub and my project can build and run in my android device.
but it leaves 8 warning message
Severity Code Description Project File Line Suppression State
Warning Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly
at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching)
at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(Disposable
1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) QrCodeManagement.Android
Warning Failed to read 'E:\File_Yudi\AndroidProject\QRCodeManagement\QrCodeManagement\QrCodeManagement.Android\obj\Release\90\linksrc\Xamarin.Forms.Platform.Android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. QrCodeManagement.Android
Warning Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly
at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching)
at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(Disposable1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) QrCodeManagement.Android
Warning Failed to read 'E:\File_Yudi\AndroidProject\QRCodeManagement\QrCodeManagement\QrCodeManagement.Android\obj\Release\90\android\assets\Xamarin.Forms.Platform.Android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. QrCodeManagement.Android
Warning Failed to read 'E:\File_Yudi\AndroidProject\QRCodeManagement\QrCodeManagement\QrCodeManagement.Android\obj\Release\90\linksrc\FormsViewGroup.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. QrCodeManagement.Android
Warning Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly
at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching)
at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(Disposable
1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) QrCodeManagement.Android
Warning Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly
at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching)
at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(Disposable1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) QrCodeManagement.Android
Warning Failed to read 'E:\File_Yudi\AndroidProject\QRCodeManagement\QrCodeManagement\QrCodeManagement.Android\obj\Release\90\android\assets\FormsViewGroup.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. QrCodeManagement.Android
Is it okay to ignore this warning message?
Crash reproducible with a standard MDP template, deployed to an S8 device.
(Whether this is specifically a Forms issue, I'm uncertain)
@iswahyudhie I am also getting these warnings but they are not causing any problem so far, so yeah ignore them.
@uzairali001 Thanks for your confirmation
I was able to get around it adding a custom proguard.cfg like described above. Works both with Proguard and r8. Tested against 4.2.0.673161-pre3 (as 4.2 GA breaks to many things for me, need to stay at this level for the moment).
While changing the ProGuard configuration didn't work for me, following https://github.com/xamarin/Xamarin.Forms/issues/5157#issuecomment-463554304 revealed the real error:
java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsFrameLayout" on path: DexPathList [...]
The solution was to include the following code in one of the Activity classes of the Android project, e.g. MainActivity.cs:
static bool falseflag = false;
static MainActivity()
{
if (falseflag)
{
var ignore = new FitWindowsFrameLayout(Application.Context);
}
}
Upon archiving I still get the original warning message but the generated package runs fine.
falseflag
is mentioned here: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/linker
@Mimisss what version of XF are you using? If it's a newer version can you attach a repro? Your exception should happen on any XF version 4.0+
I tested the original issue with the latest version of forms and I'm not see the error anymore.
Please log a new issue with a repro using the latest version of Forms if this exception still comes up for you
@PureWeen I am using Xamarin.Forms 3.4.0.1008975.
Most helpful comment
@iswahyudhie Yes, just follow one of these Method
Method 1
ProguardConfiguration
Method 2
Proguard.cfg
with notepad or any text editor just don't create it with Visual Studio, make sure its encoding is justUTF-8
not anything else. (Important)Proguard.cfg
ProGuard.cfg
file and change its Build Action toProguardConfiguration
Note: If you get java.exe exited with code 1 then your
ProGuard.cfg
file is notUTF-8
or your forget to change its Build Action toProguardConfiguration