I have stripped down my Xamarin android app in the hopes of solving why I am getting a null pointer exception in a very specific case. It includes two java binding projects and one shared code project.
Please checkout and run this solution https://github.com/frel/DemoApp
The problem is better understood by looking at the code. It is not much and I have commented a lot. But basically I am using a modified version of JohnnyCrazy Spotify Web Api to retrieve the Spotify User Account from the web. Now if I authenticate using the official Spotify Android SDK (binding project) before trying to retrieve the account, the runtime issues a null pointer exception outside my code, but a second, third or Nth attempt to call the same code results in the correct behaviour. I have added the retrieval code the the button "Send request".
Now, if I comment out the Authentication code and use the authentication token printed to the application output (see code comments), I can retrieve it on the first try without any exceptions.
Also, if I run the code in RELEASE mode it works on the first try no matter what has been called before.
EDIT: the null pointer exception seem to originate inside the WebClient class.
My guess is that perhaps bringing up the spotify login activity breaks some underlying runtime code. I am unable to comprehend why this is the case. I do not have access to VisualStudio on my license, but I suspect the debugger might help to shine some line on the situation.
I would love any assistance in this matter. And if you have any ideas as to what metadata is requried to get rid of the last binding project warnings, I would really like to hear them.
Thank you
Sincerely,
Fred