So the past 2 weekends I have once again been messing around with Xamarin development in Visual Studio. I have been following the great Lynda.com tutorial at https://www.lynda.com/Development-Tools-tutorials/Xamarin-Essential-Training/449034-2.html .
Overall is has been a great tutorial and the author goes over a fair amount in the beginning about the differences of mobile development vs regular programming and the differences of using Xamarin vs native development. This was good because I feel like alot of tutorials gloss over how it works behind the scenes.
I was very excited to give it a whirl as my previous attempts at mobile development always ended up being 90% fighting the various IDE tools. Constantly Googling compile and deployment problems. I was hopeful that after letting all of the tools marinate a year or 2, that everything would work out of the box. This was not the case, but it was easier than the last few attempts.
After setting up Xamarin and installing all of the required libraries, I loaded up the first simple, basic Android application from the tutorial. Immediately, I get errors and the program won’t work. I then try the simple, basic Android application skeleton project and get the same error. The error was:
Error: java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
Great. I did some Googling and found out I had the wrong version of the Java SDK. This was troubling because I let Visual Studio and Xamarin download everything, but whatever.
I eventually found the fix here : java Lang UnsupportedClassVersion Error in Xamarin Studio
The fix was to downloaded the latest 64-BIT Java SE Development Kit. It was important that it was the 64-bit version. So to fix, download and install the “Windows x64 Java SE Development Kit” from Oracle.
After installing it run Visual Studio and complete the following:
- Go to “Tools”, “Options”, “Xamarin”
- Click “Change” by the “Java Development Kit Location”
- Click the ellipses or “…” and then navigate to the install location of your JDK. It will probably be a bit different than the one I have listed.
- OK out of everything, close Visual Studio and re-open it.
So at this point, my code would compile, and then deploy to the Android emulator, but then flicker and crash. Fantastic. I looked at the output for any error messages and saw below. This was really the only error or warning in the console output.
AOT module 'mscorlib.dll.so' not found: dlopen failed: library
I then did some more Googling and found this post. Xamarin Forms Android App Crashes Running Debug with VS Android Emulator . The answer outlines really well what you need to do, but I will go over it here as well. I did both fixes.
Fix #1 “Could not connect to the debugger” issue (Android app starts and immediately closes, debugging stops):
- Close the Android simulator window to shut down the virtual machine.
- Start the “Hyper-V Manager” (Microsoft program to manage virtual machines in Windows, you have it installed)
- Select the emulator you are trying to use
- Right-click, hit Settings
- Expand Processor
- Click Compatibility
- In the right pane set checkbox “Migrate to a physical computer with a different processor version”
- Start the debugging in Visual Studio to restart the simulator
Fixed #2 The missing libaot-mscorlib.dll.so issue:
- Go to the properties of the Android project, hit tab “Android options”, and unselect “Use Fast Deployment”.
I tried cleaning, compiling, and deploying my app again and to my surprise…everything worked!
While not a perfect start, Xamarin development has come along way.
I looked forward to writing my
Snood, Angry Birds, Trump meme generator and becoming a gazillionaire!