Xamarin forms app crashing on startup regardless of Debug/Release - c#

I have had this weird problem with my Xamarin Forms app. It seems to crash on startup. I have tried changing the Android Linker settings but regardless of the settings it still seems to crash. It used to work on Debug mode but not working anymore. I have tried deleting the bin and obj files. I have tried deleting and updating the NuGet packages. Any help would be appreciated. I have checked in the "Main Activity" method for any missing constructors but there doesn't seem to be any missing.
Here is the stack trace below:
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotSupportedException: Could not activate JNI Handle 0xbfe1bd38 (key_handle 0xfcb6ecf) of Java type 'md5a4d2fdb8e3028a798e3d0ab6628e2c4b/MainActivity' as managed type 'TeaTotal.Droid.MainActivity'. ---> System.TypeInitializationException: The type initializer for 'TeaTotal.Droid.MainActivity' threw an exception. ---> System.MissingMethodException: Default constructor not found for type Microsoft.WindowsAzure.MobileServices.CurrentPlatform
at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00085] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/corlib/ReferenceSources/RuntimeType.cs:171
at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x0001a] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/corlib/ReferenceSources/RuntimeType.cs:153
at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x0002a] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/rttype.cs:5638
at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00040] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/activator.cs:201
at System.Activator.CreateInstance (System.Type type) [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/activator.cs:134
at Microsoft.WindowsAzure.MobileServices.Platform.get_Instance () [0x00054] in <77043900ca604149b85ba57dba9fe35b>:0
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.GetApplicationInstallationId () [0x00004] in <77043900ca604149b85ba57dba9fe35b>:0
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor (System.Uri applicationUri, System.String applicationKey, System.Net.Http.HttpMessageHandler[] handlers) [0x00028] in <77043900ca604149b85ba57dba9fe35b>:0
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor (System.Uri applicationUri, System.String applicationKey) [0x00000] in <77043900ca604149b85ba57dba9fe35b>:0
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor (System.Uri applicationUri) [0x00000] in <77043900ca604149b85ba57dba9fe35b>:0
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor (System.String applicationUrl) [0x00007] in <77043900ca604149b85ba57dba9fe35b>:0
at TeaTotal.Droid.MainActivity..cctor () [0x00000] in C:\TT\Droid\MainActivity.cs:31

Related

Visual Studio Xamarin.Forms Debugging: How to step into an external library method?

Sometimes an exception is thrown from inside the Xamarin.Forms external library and it would be extremely helpful to view the pertinent local variables in the debugger as we would in our own code.
Here is the stacktrace of my current Android iOS project headache:
System.InvalidCastException: Specified cast is not valid.
at Xamarin.Forms.BindableLayoutController.CreateItemView (System.Object item, Xamarin.Forms.DataTemplate dataTemplate) [0x00003] in D:\a\1\s\Xamarin.Forms.Core\BindableLayout.cs:261
at Xamarin.Forms.BindableLayoutController.CreateItemView (System.Object item, Xamarin.Forms.Layout`1[T] layout) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableLayout.cs:254
at Xamarin.Forms.BindableLayoutController.CreateChildren () [0x00040] in D:\a\1\s\Xamarin.Forms.Core\BindableLayout.cs:234
at Xamarin.Forms.BindableLayoutController.SetItemTemplate (Xamarin.Forms.DataTemplate itemTemplate) [0x0005a] in D:\a\1\s\Xamarin.Forms.Core\BindableLayout.cs:180
at Xamarin.Forms.BindableLayoutController.set_ItemTemplate (Xamarin.Forms.DataTemplate value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableLayout.cs:127
at Xamarin.Forms.BindableLayout+<>c.<.cctor>b__19_1 (Xamarin.Forms.BindableObject b, System.Object o, System.Object n) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableLayout.cs:16
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:311
at Xamarin.Forms.BindableLayout.SetItemTemplate (Xamarin.Forms.BindableObject b, Xamarin.Forms.DataTemplate value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableLayout.cs:45
at SecretProjectName.Views.YourAmazingClassPage..ctor () [0x0005b] in C:\Users\UserName\source\repos\SecretProjectName\SecretProjectName\SecretProjectName\Views\YourAmazingClassPage.xaml.cs:20
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:936
Is there any other way to do this than forking Xamarin.Forms source code into my project?
DLLs are always compiled, thus you can't step in. They don't contain your (or someone elses) code in its source, it is modified by the process of compilation.

C# The type initializer for 'Newtonsoft.Json.Serialization.DefaultSerializationBinder' [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
What I'm trying to do is convert a JSON file into arrays that I can utilize later on in the C# script but for some reason, I can't get it to work. Either the JSON lib doesn't want to load or when I do get it to load I get these errors, no matter how simple the JSON file is.
The worst part is that I've got this to work in another script but for some reason, it refuses to work here. I've gone through the old one trying to figure out what I'm missing but I can't find it.
So instead of trying to just read a simple JSON file I'll give you the full thing I need to do and hopefully someone can help me out in here.
Code:
public List<string> PostalCodes = new List<string>();
public Client()
{
try
{
string postals = LoadResourceFile(GetCurrentResourceName(), "new-postals.json");
Debug.WriteLine(postals); // Outputs properly, actually can see the stuff
dynamic array = JsonConvert.DeserializeObject(postals); //Newtonsoft.Json
Debug.WriteLine(array[0]); // Not working at all.
}
catch (Exception e)
{
Debug.WriteLine($"^3[DEBUG] ^0Error info: {e.Message.ToString()}\r\n\r\n");
throw;
}
}
JSON File:
[
{
"x":2325.4345703125,
"y":5147.21484375,
"code":"2000"
},
{
"x":2151.2138671875,
"y":5166.0888671875,
"code":"2001"
},
// And so on.
]
If you wonder what LoadResourceFile it's loading and reading the file for me in one line of code.
Edit:
First, let me start by apologizing. As I'm still new to this I didn't include the whole error message as the rest that was given to me didn't look like it was useful.
[DEBUG] ^0Error info: The type initializer for 'Newtonsoft.Json.Serialization.DefaultSerializationBinder' threw an exception.
MainThrd/ Failed to instantiate instance of script Client: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Newtonsoft.Json.Serialization.DefaultSerializationBinder' threw an exception. ---> System.MethodAccessException: Error verifying Newtonsoft.Json.Serialization.DefaultSerializationBinder:.ctor (): Method System.Runtime.Serialization.SerializationBinder:.ctor () is not accessible at 0x0001
MainThrd/ at Newtonsoft.Json.Serialization.DefaultSerializationBinder..cctor () [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ --- End of inner exception stack trace ---
MainThrd/ at Newtonsoft.Json.JsonSerializer.Create () [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ at Newtonsoft.Json.JsonSerializer.Create (Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ at Newtonsoft.Json.JsonSerializer.CreateDefault () [0x00011] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ at Newtonsoft.Json.JsonSerializer.CreateDefault (Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0000b] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0
MainThrd/ at Client..ctor () [0x00071] in <7b9b05cb23034b40bf8a5d2ade61e392>:0
MainThrd/ at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
MainThrd/ at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <74fbbe963b7e417b8d715b858c5c584f>:0
MainThrd/ --- End of inner exception stack trace ---
MainThrd/ at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <74fbbe963b7e417b8d715b858c5c584f>:0
MainThrd/ at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in <74fbbe963b7e417b8d715b858c5c584f>:0
MainThrd/ at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <74fbbe963b7e417b8d715b858c5c584f>:0
MainThrd/ at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <74fbbe963b7e417b8d715b858c5c584f>:0
MainThrd/ at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <74fbbe963b7e417b8d715b858c5c584f>:0
MainThrd/ at System.Activator.CreateInstance (System.Type type) [0x00000] in <74fbbe963b7e417b8d715b858c5c584f>:0
MainThrd/ at CitizenFX.Core.InternalManager.CreateAssemblyInternal (System.String assemblyFile, System.Byte[] assemblyData, System.Byte[] symbolData) [0x000b1] in C:\gl\builds\edf06b9b\0\cfx\fivem\code\client\clrcore\InternalManager.cs:134
I did, however, get it to work with the answer below and changing the project reference. I did try the code first but it didn't resolve anything, I read a bit more about the problem and I decided to change the project reference after and just gave it a test run. It works perfectly now. Thank you all so much for all the help. Greatly appreciated!
Project Reference (CSPROJ)
// FROM
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
// TO
<PackageReference Include="Newtonsoft.Json" Version="12.0.0" ExcludeAssets="Compile" GeneratePathProperty="true" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\portable-net40+sl5+win8+wp8+wpa81\Newtonsoft.Json.dll</HintPath>
</Reference>
Welcome to C#!
My first suggestion would be to avoid dynamic unless you have a good use case for it. In this scenario, I'd create a class to match your data
public class Data
{
public double X { get; set; }
public double Y { get; set; }
public string Code { get; set; }
}
Then use the generic version of DeserializeObject to type your deserialization, such as
var array = JsonConvert.DeserializeObject<List<Data>>(postals);

UITest failed with : "SetUp : System.InvalidOperationException"

I can't use UITest anymore with my xamarin project since the last update of xamarin on the stable channel with Xcode 8.2.
Everytime, when I launch the test, I have an error : "SetUp : System.InvalidOperationException : Sequence contains no matching element". My test series doesn't change from a long time and works well before...
So I don't know how to correct this problem now...
The stack trace :
at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func2[T,TResult] predicate) [0x00065] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System.Core/System/Linq/Enumerable.cs:965
at Xamarin.UITest.iOS.Instruments.GetAutomationTemplatePath () [0x00031] in :0
at Xamarin.UITest.iOS.Instruments.StartInstrumentsInternal (System.String targetApplication, Xamarin.UITest.iOS.iOSRunType runType, System.String deviceId, System.String runLoopPath, Xamarin.UITest.Configuration.AppDataMode appDataMode, System.Predicate`1[T] dropLine) [0x00006] in :0
at Xamarin.UITest.iOS.Instruments.StartInstruments (System.String targetApplication, Xamarin.UITest.iOS.iOSRunType runType, System.String deviceId, Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00012] in :0
at Xamarin.UITest.iOS.iOSAppLauncher.RunAppInEmulatorInternal (System.String application, Xamarin.UITest.iOS.Instruments instruments, Xamarin.UITest.Shared.Http.HttpClient httpClient, System.Uri deviceUri, Xamarin.UITest.Shared.Artifacts.ArtifactFolder artifactFolder, Xamarin.UITest.Configuration.AppDataMode appDataMode, System.String deviceIdentifier) [0x00095] in :0
at Xamarin.UITest.iOS.iOSAppLauncher.RunAppInEmulator (Xamarin.UITest.Shared.iOS.AppBundle appBundle, Xamarin.UITest.iOS.Instruments instruments, Xamarin.UITest.Shared.Http.HttpClient httpClient, System.Uri deviceUri, Xamarin.UITest.Shared.Artifacts.ArtifactFolder artifactFolder, Xamarin.UITest.Configuration.AppDataMode appDataMode, System.String deviceIdentifier) [0x00099] in :0
at Xamarin.UITest.iOS.iOSAppLauncher.LaunchApp (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Http.HttpClient httpClient, Xamarin.UITest.TestCloud.TestCloudiOSAppConfiguration testCloudAppConfiguration, Xamarin.UITest.Shared.Http.HttpClient testCloudWsClient) [0x000e4] in :0
at Xamarin.UITest.iOS.iOSApp..ctor (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration) [0x002db] in :0
at Xamarin.UITest.Configuration.iOSAppConfigurator.StartApp (Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in :0
at Ac.Test.TestV35.BeforeEachTest () [0x00012] in /Users/ShaprAdmin/Documents/ac/Ac.Test/TestV35.cs:17
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
Thank you!
try to grab the newest Xcode and
then beside proper NUnit version (2.6.x and proper NUnitTestAdapter 2.1.0)
try do upgrade/downgrade the Xamarin.UITest package to version 2.5.
For me it was not working (with same error) for 2.7 for 2.5 it's ok.
Regards,

System.IO.FileNotFoundException: On InitializeComponent caused by own control

I have problems creating own control: I'm trying to make grid view similar to list view. The problem is in xaml file of the page - when I'm initializing my component app crashes on that page with file not found exception.
Error says: System.IO.FileNotFoundException Could not load file or assembly 'FastFood' or one of its dependencies. The system cannot
find the file specified.
Callstack:
_at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity)
[0x00081] in
/Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System/AppDomain.cs:706
at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in
/Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System/AppDomain.cs:674
at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in
/Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/Assembly.cs:551
at Xamarin.Forms.Xaml.XamlParser.GetElementType (Xamarin.Forms.Xaml.XmlType xmlType, IXmlLineInfo xmlInfo,
System.Reflection.Assembly currentAssembly,
Xamarin.Forms.Xaml.XamlParseException& exception) [0x00133] in :0
at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x0002a] in
:0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x000b1] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00089] in :0
at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00064] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x000a4] in
:0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x0002e]
in :0
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[CategoryPage] (FastFood.CategoryPage view, System.Type callingType) [0x00000] in :0
at FastFood.CategoryPage.InitializeComponent () [0x0000c] in /Users/Slider/Coffetab/iOS/obj/iPhoneSimulator/Debug/FastFood.iOS..Users.Slider.Coffetab.FastFood.CategoryPage.xaml.g.cs:33
at FastFood.CategoryPage..ctor () [0x0001a] in /Users/Slider/Coffetab/FastFood/CategoryPage.xaml.cs:25
at FastFood.MenuPage..ctor () [0x0004b] in /Users/Slider/Coffetab/FastFood/MenuPage.xaml.cs:14
at FastFood.MainPage.OnLogin (System.Object sender, System.EventArgs e) [0x0002f] in
/Users/Slider/Coffetab/FastFood/MainPage.xaml.cs:29
at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked ()
[0x00020] in :0
at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (System.Object sender, System.EventArgs eventArgs) [0x0000e] in :0
at UIKit.UIControlEventProxy.Activated () [0x00007] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIControl.cs:37
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in
/Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:77
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in
/Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:61
at FastFood.iOS.Application.Main (System.String[] args) [0x0001a] in /Users/Slider/Coffetab/iOS/Main.cs:23_
What I'm doing wrong?
Years later (for you) but I found a solution on a forum.
I've encountered this some other times with other components and NuGet
packages. You'll probably have to live with the fact that you have to
include a dummy line of code which instantiates the ExtendedSlider. It
doesn't have to do anything, just reference it somewhere.
When you're using it in just XAML the compiler doesn't detect the
reference and thus excludes the needed dll. Until the creator of the
component finds some fix for this you'll have to use this workaround.
Source: https://forums.xamarin.com/discussion/comment/187222/#Comment_187222
So just add a random var foo = new YourComponentFromTheAssemblyInQuestion(); anywhere in your code and it shouldn't complain anymore.
Maybe this will help others stumbling upon the same issue later on like I did.

App crashes in release mode and not in debug mode - Xamarin Forms

I am building a cross platform app and i want to release it to testers, but it doesn't work when i am deploying it in release mode. As far as exceptions go i do not get any. As stated in the question it works in debug mode. The app just goes to splashscreen and crashes. I ran the original app through test fairy and got this exception:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
... 2 more
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.IO.FileNotFoundException: Could not load file or assembly '<Censored: Name of forms class library>.dll' or one of its dependencies. The system cannot find the file specified.
File name: '<Censored: Name of forms class library>.dll'
at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x00000] in :0
at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlParser.GetElementType (Xamarin.Forms.Xaml.XmlType xmlType, IXmlLineInfo xmlInfo, System.Reflection.Assembly currentAssembly, Xamarin.Forms.Xaml.XamlParseException& exception) [0x00000] in :0
at (wrapper delegate-invoke) :invoke_Type_XmlType_IXmlLineInfo_Assembly_XamlParseException& (Xamarin.Forms.Xaml.XmlType,System.Xml.IXmlLineInfo,System.Reflection.Assembly,Xamarin.Forms.Xaml.XamlParseException&)
at Xamarin.Forms.Xaml.XamlTypeResolver.Resolve (System.String qualifiedTypeName, IServiceProvider serviceProvider, Xamarin.Forms.Xaml.XamlParseException& exception) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlTypeResolver.TryResolve (System.String qualifiedTypeName, System.Type& type) [0x00000] in :0
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor+MarkupExpansionParser.Parse (System.String match, System.String& remaining, IServiceProvider serviceProvider) [0x00000] in :0
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor.ParseExpression (System.String& expression, IXmlNamespaceResolver nsResolver, IXmlLineInfo xmlLineInfo, INode node, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor.Visit (Xamarin.Forms.Xaml.MarkupNode markupnode, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.MarkupNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in :0
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[LoginPage] (<Censored>.Login.LoginPage view, System.Type callingType) [0x00000] in :0
at <Censored>.Login.LoginPage.InitializeComponent () [0x00000] in :0
at <Censored>.Login.LoginPage..ctor () [0x00000] in :0
at <Censored>.App.b__0 () [0x00000] in :0
at <Censored>.ViewFactory.Resolve[LoginViewModel] (<Censored>.Login.LoginViewModel viewModel) [0x00000] in :0
at <Censored>.App..ctor () [0x00000] in :0
at md5b406f03a919343acc4f3b337a44e1248.MainActivity.n_onCreate(Native Method)
at md5b406f03a919343acc4f3b337a44e1248.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:5458)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.access$900(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
... 5 more
I cannot show you the source code, but i have reproduced the error in a new test solution.
Here is a link to the repository with the test project. It is just a project using MVVM with Xamarin Forms.
Fixed it by manually deleting all obj folders and all bin folders in the entire solution.
Edit: Came back again and now this fix does not work!
If your solution works in Debug mode, but not in Release mode, it might be an issue with the Linker.
Right Click on your specific project (not Solution) -> Android Options -> Linker -> Choose "None" in Linking. This will include all dlls in the Release Library.

Categories

Resources