Similar to this question
A workaround I found was to uninstall and re-install the app.
However, it may be difficult to convince users on the play store to do that, as they may not read the update change-log before downloading. (e.g. auto-update).
I narrowed down the cause to:
09-28 21:41:26.011: I/MonoDroid(6923): UNHANDLED EXCEPTION:
09-28 21:41:26.047: I/MonoDroid(6923): Java.Lang.RuntimeException: Binary XML file line #1: Error inflating class android.widget.ImageButton ---> Java.Lang.Exception: Exception of type 'Java.Lang.Exception' was thrown. ---> Java.Lang.RuntimeException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010127 a=-1}
09-28 21:41:26.047: I/MonoDroid(6923): --- End of inner exception stack trace ---
09-28 21:41:26.047: I/MonoDroid(6923): --- End of inner exception stack trace ---
09-28 21:41:26.047: I/MonoDroid(6923): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <9ab6e5aa0dab475cab5597fa4269890c>:0
09-28 21:41:26.047: I/MonoDroid(6923): at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <5e50b69e5a0e439f924bf0f2e8fcd52c>:0
09-28 21:41:26.047: I/MonoDroid(6923): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <5e50b69e5a0e439f924bf0f2e8fcd52c>:0
09-28 21:41:26.047: I/MonoDroid(6923): at Android.App.Activity.SetContentView (System.Int32 layoutResID) [0x00022] in <f051fcdec18c4806998a5576ba788eec>:0
09-28 21:41:26.047: I/MonoDroid(6923): at mypackagename.MainActivity+<OnCreate>d__33.MoveNext () [0x0004d] in <467e37befb3d49c788d8cebf5dfb11a2>:0
09-28 21:41:26.047: I/MonoDroid(6923): --- End of stack trace from previous location where exception was thrown ---
09-28 21:41:26.047: I/MonoDroid(6923): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <9ab6e5aa0dab475cab5597fa4269890c>:0
09-28 21:41:26.047: I/MonoDroid(6923): at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <9ab6e5aa0dab475cab5597fa4269890c>:0
09-28 21:41:26.047: I/MonoDroid(6923): at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <f051fcdec18c4806998a5576ba788eec>:0
09-28 21:41:26.047: I/MonoDroid(6923): at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <f051fcdec18c4806998a5576ba788eec>:0
09-28 21:41:26.047: I/MonoDroid(6923): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <f051fcdec18c4806998a5576ba788eec>:0
09-28 21:41:26.047: I/MonoDroid(6923): at (wrapper dynamic-method) System.Object:471f272e-f7ed-4fdc-805d-59ce5a399fd4 (intptr,intptr)
09-28 21:41:26.047: I/MonoDroid(6923): --- End of managed Java.Lang.RuntimeException stack trace ---
09-28 21:41:26.047: I/MonoDroid(6923): android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.ImageButton
Old apk was built using Xamarin.VisualStudio_4.5.0.486 on VS Community 2015.3
New apk was build using Xamarin.VisualStudio_4.6.3.4 on VS Community 2017
both apk targets Nougat 7.0, and minimum ICS 4.0.3
There was no change whatsoever to my axml layout files. That is also evident because after re-installation, the ImageButton inflates without any problem.
How can this issue be resolved?
Related
I get this error when I try to compile csharp or fsharp files. This happens when using gnome terminal or jetbrain rider.
It works fine in tty or termials like xterm and urxvt.
Also I am able to compile c, c++ and go code.
Btw, I am using Arch/Antergos and got this issue yesterday.
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542
at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x00028] in :0
at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in :0
at System.TermInfoDriver..ctor (System.String term) [0x00055] in :0
at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in :0
at System.ConsoleDriver..cctor () [0x0004d] in :0
--- End of inner exception stack trace ---
at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in :0
at System.Console..cctor () [0x0008e] in :0
--- End of inner exception stack trace ---
at Mono.CSharp.Driver.Main (System.String[] args) [0x00019] in <2b1e99ce45b54209bdcdab138d9758ae>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542
at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x00028] in :0
at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in :0
at System.TermInfoDriver..ctor (System.String term) [0x00055] in :0
at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in :0
at System.ConsoleDriver..cctor () [0x0004d] in :0
--- End of inner exception stack trace ---
at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in :0
at System.Console..cctor () [0x0008e] in :0
--- End of inner exception stack trace ---
at Mono.CSharp.Driver.Main (System.String[] args) [0x00019] in <2b1e99ce45b54209bdcdab138d9758ae>:0
I'm working on AzureStorage cloud solution provided by Xamarin.
https://developer.xamarin.com/guides/xamarin-forms/cloud-services/storage/azure-storage/
And this is what I got in GetContainer() method.
The type initializer for
'Microsoft.WindowsAzure.Storage.CloudStorageAccount' threw an
exception
I applied my connection string in the sample project and it worked, but not in my own project.
Has anyone ever faced this issue? Please help me.
Thanks in advance.
Error message :
System.TypeInitializationException: The type initializer for 'Microsoft.WindowsAzure.Storage.CloudStorageAccount' threw an exception. ---> System.NotImplementedException: The method or operation is not implemented.
at Microsoft.WindowsAzure.Storage.CloudStorageAccount.Setting (System.String name, System.String[] validValues) [0x00000] in <667a5fa37f124e50ab7a68ecb3437b13>:0
at Microsoft.WindowsAzure.Storage.CloudStorageAccount..cctor () [0x00000] in <667a5fa37f124e50ab7a68ecb3437b13>:0
--- End of inner exception stack trace ---
at MyTenantWorld.AzureStorage.GetContainer (MyTenantWorld.ContainerType containerType) [0x00020] in <9816076ee17d42efaf1050c5169a4310>:0
at MyTenantWorld.AzureStorage+<UploadFileAsync>d__3.MoveNext () [0x0001a] in <9816076ee17d42efaf1050c5169a4310>:0
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at MyTenantWorld.SettingsPage+<SaveData>d__20.MoveNext () [0x00309] in <9816076ee17d42efaf1050c5169a4310>:0
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <d855bac285f44dda8a0d8510b679b1e2>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d855bac285f44dda8a0d8510b679b1e2>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <d855bac285f44dda8a0d8510b679b1e2>:0
at at (wrapper dynamic-method) System.Object:a4fed05a-cd7a-4756-85bb-5dd975374042 (intptr,intptr)
As the GetContainer method defined under AzureStorage.cs as follows:
static CloudBlobContainer GetContainer(ContainerType containerType)
{
var account = CloudStorageAccount.Parse(Constants.StorageConnection);
var client = account.CreateCloudBlobClient();
return client.GetContainerReference(containerType.ToString().ToLower());
}
It seems that the error was thrown by CloudStorageAccount.Parse, but from BergQuester's link about CloudStorageAccount.Parse, we could find that this error is not from the predictable exceptions.
From your stack trace, we could find the error was thrown at Setting(string name, params string[] validValues) from CloudStorageAccount.cs. I used WindowsAzure.Storage 8.3.0 and tested it under my BruceChen_Mobile.UWP project and PCL project, it could work as expected with my azure storage connection string.
I applied my connection string in the sample project and it worked, but not in my own project.
I would recommend you checking the packages between your application and the xamarin-forms-samples. Or you could provide a reproducible sample project for us to narrow this issue.
I fixed this issue on mine by adding a reference to the WindowsAzure.Storage nuget package from my native projects (not just in the PCL project), as it requires some native implementations that are defined in these references.
I created a simple Xamarin.Forms App to check HTTPS using https://jsonplaceholder.typicode.com/.
But the App crashes using HTTPS.
public RestService() {
client = new HttpClient();
client.MaxResponseContentBufferSize = 256000;
}
public async Task<List<Item>> RefreshDataAsync() {
string url = "http://jsonplaceholder.typicode.com/posts";
// Crash using this URL
//string url = "https://jsonplaceholder.typicode.com/posts";
var uri = new Uri(string.Format(url, string.Empty));
List<Item> Items = new List<Item>();
var content = await client.GetStringAsync(uri);
Items = JsonConvert.DeserializeObject<List<Item>>(content);
return Items;
}
}
Is it a problem with the website or httpClient or do I do somethin wrong ?
Thats the Exception
{System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: SecureChannelFailure (The authentication or decryption has failed.) ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x00037] in <d2bf9ddce2b945f79db1e7c4354bafea>:0
at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in <d2bf9ddce2b945f79db1e7c4354bafea>:0
at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in <d2bf9ddce2b945f79db1e7c4354bafea>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) [0x00032] in <d2bf9ddce2b945f79db1e7c4354bafea>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) [0x0000c] in <d2bf9ddce2b945f79db1e7c4354bafea>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (System.IAsyncResult asyncResult) [0x0004b] in <d2bf9ddce2b945f79db1e7c4354bafea>:0
at Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsClient (System.IAsyncResult asyncResult) [0x0000e] in <a547bd0d78184f26ab08d022f013c1e1>:0
at Mono.Net.Security.Private.LegacySslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0000e] in <a547bd0d78184f26ab08d022f013c1e1>:0
at Mono.Net.Security.MonoTlsStream.CreateStream (System.Byte[] buffer) [0x0007b] in <a547bd0d78184f26ab08d022f013c1e1>:0
at System.Net.WebConnection.CreateStream (System.Net.HttpWebRequest request) [0x00073] in <a547bd0d78184f26ab08d022f013c1e1>:0
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00058] in <a547bd0d78184f26ab08d022f013c1e1>:0
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <3fd174ff54b146228c505f23cf75ce71>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x003e6] in <b696532a7c264e5e866cb15a1b40a4a4>:0
--- End of inner exception stack trace ---
at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x00449] in <b696532a7c264e5e866cb15a1b40a4a4>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClient+<SendAsyncWorker>d__49.MoveNext () [0x000ca] in <b696532a7c264e5e866cb15a1b40a4a4>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Net.Http.HttpClient+<GetStringAsync>d__55.MoveNext () [0x0007d] in <b696532a7c264e5e866cb15a1b40a4a4>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at getWeather.RestService+<RefreshDataAsync>d__2.MoveNext () [0x0006e] in C:\Users\afelde\documents\visual studio 2017\Projects\getWeather\getWeather\getWeather\RestService.cs:30 }
That Post on Xamarin.Forum also solve the Issue without installing any Nuget Packages :
As #SvetlomirKalitsov describes, the two settings below take care of
the issue:
HttpClient implementation -> AndroidClientHandler SSL/TLS
implementation -> Native TLS 1Here is where I made the mistake: There
are two pretty similar options: Native TLS 1.2+ which is the correct
one, and Default (Native TLS 1.2+). This second one (Default) will
fail. Make sure to select the non-default one; in other words, make
sure to force that option instead of relying on the Default.
A bit of background info: XA_HTTP_CLIENT_HANDLER_TYPE environment
variable on Xamarin.Android
Thanks #SvetlomirKalitsov
I found a post about your issue (https://forums.xamarin.com/discussion/10405/the-authentication-or-decryption-has-failed-in-the-web-request)
Here in the comments you will find someone suggesting to use the package modernhttpclient
The way to work with this package:
HttpClient client = new HttpClient(new NativeMessageHandler());
The NativeMessagehandler will solve the certifcations issue ( since u using https it gave a authentication error, this will solve it)
For the rest you can use the client as you were already using it.
Good luck
This problem has kind of stumpped me for the last couple of hours. Any clue why the application is crashing with this callstack in monodevelop. It will compile and run correctly if I build the application with xbuild.
Unhandled Exception:
System.Net.WebException: An exception occurred during a WebClient request. ---> System.TypeInitializationException: The type initializer for 'System.Net.WebRequest' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.TypeLoadException: Failure has occurred while loading a type.
at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00065] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/Configuration.cs:137
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x0005c] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/Configuration.cs:96
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x0003b] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/Configuration.cs:91
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000e] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/InternalConfigurationFactory.cs:41
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00102] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:119
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00011] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:49
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00025] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:52
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:61
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:159
at System.Net.WebRequest..cctor () [0x00014] in /builddir/build/BUILD/mono-4.2.3/mcs/class/System/System.Net/WebRequest.cs:71
--- End of inner exception stack trace ---
at System.Net.WebClient.GetWebRequest (System.Uri address) [0x00000] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/System/net/System/Net/webclient.cs:285
at ParkitectNexus.Data.Web.Client.NexusWebClient.GetWebRequest (System.Uri uri) [0x00003] in /home/michaelpollind/Desktop/ParkitectNexusClient/src/ParkitectNexus.Data/Web/Client/NexusWebClient.cs:70
at System.Net.WebClient.OpenReadAsync (System.Uri address, System.Object userToken) [0x0003b] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/System/net/System/Net/webclient.cs:1846
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372
at ParkitectNexus.Data.Web.API.ParkitectNexusAPI+<GetRequiredModIdentifiers>c__async1.MoveNext () [0x000b8] in /home/michaelpollind/Desktop/ParkitectNexusClient/src/ParkitectNexus.Data/Web/API/ParkitectNexusAPI.cs:86
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372
at ParkitectNexus.Client.Base.Pages.AssetsPageView+<GetRequiredMods>c__async0.MoveNext () [0x0007c] in /home/michaelpollind/Desktop/ParkitectNexusClient/src/ParkitectNexus.Client.Base/Pages/AssetsPageView.cs:62
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__1 (System.Object state) [0x00000] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1010
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x0000e] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/threading/threadpool.cs:1291
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, Boolean preserveSyncCtx) [0x00081] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/threading/executioncontext.cs:581
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, Boolean preserveSyncCtx) [0x00000] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/threading/executioncontext.cs:530
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x0002a] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/threading/threadpool.cs:1268
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/threading/threadpool.cs:859
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in /builddir/build/BUILD/mono-4.2.3/external/referencesource/mscorlib/system/threading/threadpool.cs:1196
After some testing I found that creating a separate project and copying everything into it seems to have resolved the configuration error. If anyone has any insight into this, I would like to know.
The following post looks similar to my issue, but ultimately it doesn't look exactly the same down to all the details, so I am calling that out to prevent claims that its the same.
I am following this monogame tutorial (currently on step 2) in Xamarin Studio:
When I run the resulting monogame app at the end of step 2 I get the following exception (pasted at the end) when I hit the line of code that attempts to load the player content. I have the player content file setup correctly AFAIK, its copied to the output folder, but I am assuming that its somehow not deployed correctly to the Andriod Virtual Machine (AVM), which I have not been able to figure out how to examine the deployed contents. I pulled up Android Monitor to explore the AVM and try to figure out where things are, but I haven't had any luck figuring that out... The file not found exception seems to be clear that what's running on the AVM isn't finding the content file... but I can't figure out how to correct that.
Any help would be appreciated, thanks!
The sources and project that I am having this issue with are here
The exception I am seeing is the following:
[MonoDroid] UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [MonoDroid] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [MonoDroid] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [MonoDroid] --- End of managed exception stack trace --- [MonoDroid] java.io.FileNotFoundException: Content/Graphics/player.xnb [MonoDroid] at android.content.res.AssetManager.openAsset(Native Method) [MonoDroid] at android.content.res.AssetManager.open(AssetManager.java:315) [MonoDroid] at android.content.res.AssetManager.open(AssetManager.java:289) [MonoDroid] at mono.java.lang.RunnableImplementor.n_run(Native Method) [MonoDroid] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29) [MonoDroid] at android.os.Handler.handleCallback(Handler.java:605) [MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:92) [MonoDroid] at android.os.Looper.loop(Looper.java:137) [MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:4424) [MonoDroid] at java.lang.reflect.Method.invokeNative(Native Method) [MonoDroid] at java.lang.reflect.Method.invoke(Method.java:511) [MonoDroid] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) [MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) [MonoDroid] at dalvik.system.NativeStart.main(Native Method) [MonoDroid] [MonoDroid] --- End of inner exception stack trace --- [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[Texture2D] (System.String assetName, System.Action1 recordDisposableObject) [0x00000] in :0
[MonoDroid] --- End of inner exception stack trace ---
[MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset (string,System.Action1) <0x0042c> [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.Load (string) <0x000c3> [MonoDroid] at SampleShooter.Game1.LoadContent () <0x0018b> [MonoDroid] at Microsoft.Xna.Framework.Game.Initialize () <0x0023f> [MonoDroid] at SampleShooter.Game1.Initialize () <0x00037> [MonoDroid] at Microsoft.Xna.Framework.Game.DoInitialize () <0x00037> [MonoDroid] at Microsoft.Xna.Framework.AndroidGamePlatform.BeforeUpdate (Microsoft.Xna.Framework.GameTime) <0x0002b> [MonoDroid] at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime) <0x0002f> [MonoDroid] at Microsoft.Xna.Framework.Game.Tick () <0x00493> [MonoDroid] at Microsoft.Xna.Framework.AndroidGameWindow.OnUpdateFrame (OpenTK.FrameEventArgs) <0x000a7> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView.UpdateFrameInternal (OpenTK.FrameEventArgs) <0x00033> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView.RunIteration (System.Threading.CancellationToken) <0x001c3> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView/c__AnonStorey0.<>m__2 (object) <0x00027> [MonoDroid] at Android.App.SyncContext/c__AnonStorey2F.<>m__1A () <0x00023> [MonoDroid] at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f> [MonoDroid] at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x00037> [MonoDroid] at (wrapper dynamic-method) object.e85befee-f4e0-4f15-9232-77621081c7b5 (intptr,intptr) <0x0003b> [mono] [mono] Unhandled Exception: [mono] Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [mono] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [mono] --- End of managed exception stack trace --- [mono] java.io.FileNotFoundException: Content/Graphics/player.xnb [mono] at android.content.res.AssetManager.openAsset(Native Method) [mono] at android.content.res.AssetManager.open(AssetManager.ja [mono] [ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [mono] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [mono] --- End of managed exception stack trace --- [mono] java.io.FileNotFoundException: Content/Graphics/player.xnb [mono] at android.content.res.AssetManager.openAsset(Native Method) [mono] at android.content.res.AssetManager.open(As
So I finally figured out that I needed to mark the XNB file as an AndroidAsset for the build action, and not Content as the example stated. Since the example I am following is aimed at Windows Mobile development this makes sense since the file would normally be marked as content for a Windows application, whereas for Android these files need to be marked as AndriodAsset in order for XNA to be able to access the raw content data, regardless of if the file is in a content or asset folder. The content manager's root folder by default is "Content", so you need to add the file there and mark it as an asset, not content...
Content for an android monogame project should be added to the project in the Assets/Content folder as built .xnb files rather than just copied to the output directory