InvalidCastException when casting to Applicaiton class after Mono upgrade - xamarin.android

I just started up my project in MonoDevelop again after not having looked at it for a few months. Of course there was a new version for Mono, MonoDevelop and Mono for Android.
As soon as I run the app I get a InvalidCastException when casting to my Application class in one of my activities:
Error:System.InvalidCastException: Cannot cast from source type to destination type.
The line comes from
ConferenceApplication conferenceApplication = ((ConferenceApplication)base.Application);
When I print the base.Application.Class it reports mono.android.app.Application and not my own application class. My application class is denoted with [Application] and extends Android.App.Application.
I'm pretty confident that the app has not been changed since the last time I ran it. What could the cause for this problem be? And how can I fix it?
I'm using the Beta channel for updates.
MonoDevelop 3.0.4.7
Mono 2.10.9
Mono for Android: 4.2.8

I downgraded to latest stable of Mono for Android - 4.2.6 - and it all magically just worked.

Related

How to test if flag BUILD_LIBRARY_FOR_DISTRIBUTION = TRUE works

I got a complaint from a client that library i made was throwing an error when they try to import it. Error is saying: "Module compiled with Swift 5.3 cannot be imported by the Swift 5.4 compiler". After some research i found out about ABI, and I understand the cause of this error.
Now I want to test if this solution works before shipping the fix. I downloaded a few older toolchain versions hoping that by switching them I could simulate this kind of situation. Setting the distribution flag for the library, building it with older toolchain and then importing it to a project with newest version of toolchain. However I still get the same error. Im I doing this right? What I am missing?

Invalid redeclaration of 'SwiftEntryPlugin'

I developed a flutter app on an Ubuntu machine and it works without problems on Android. Now I am trying to run it on iOS from a Mac but when I start debugging, I get several errors like the following:
/opt/flutter/.pub-cache/hosted/pub.dartlang.org/entry-0.0.2_2/ios/Classes/SwiftAnimateInPlugin.swift:4:14: error: invalid redeclaration of 'SwiftEntryPlugin'
public class SwiftEntryPlugin: NSObject, Flutter Plugin {
^
flutter doctor passes for Flutter, Xcode, and Connected device.
Flutter 2.2.0 - channel stable
Tools - Dart 2.13.0
I have checked this question but they are not using Flutter and the answers are not relevant as far as I can tell. What would cause this error and how might I resolve it?
Taking Nisanth Reddy's advice from the comment above and grepping for SwiftEntryPlugin: NSObject my search was narrowed down to 2 files. The files were ./my-app/ios/.symlinks/plugins/entry/ios/Classes/SwiftEntryPlugin.swift and ./my-app/ios/.symlinks/plugins/entry/ios/Classes/SwiftAnimateInPlugin.swift. After some trial and error, it seems like both files are required (the redundant one being required by a particular Flutter package I'm using, I think) but both had the exact same code in them so I removed all the code from one of the files but left the empty file sitting there in the directory and the problem was resolved.

LOCKDOWN_E_PLIST_ERROR when launching on iOSDevice (iPhone 6)

With: Eclipse Neon, Gluon plug in, Gradle plug in - exporting javaFX to iOS. Exporting from a mac book air mid 2013.
Since: Today, after I installed the new iOS 11 update. It worked 2 weeks ago with the previous version of the OS.
The error LOCKDOWN_E_PLIST_ERROR is given in the eclipse console when I LaunchIOSDevice - a Gradle task. How come? How can it be solved?
Some background information: After managing to set up eclipse, gluon, and gradle onto my mac (which where necessary to export to iOS javaFX based projects). I had some problems exporting/building it to iOS. I had to increase the max working memory up to 2 gbg by altering the Eclipse.ini - file. I also solved another type of problem (the Default-Info.plist file inside the gluonprojects) - Where I had to create a new such file from inside Xcode and change the the package name given inside it, and somehow connected to my AppleDeveloper account. Then I replaced the plist file inside the gluonproject and it all worked fine...
Until now, when I have come across this new error that I need help with!

Xamarin Forms cross-platform map issue on Android

After upgrading Xamarin Forms and Maps to version 2.3.3.193, on my Android app, I now receive the following error when I attempt to display a map:
{Xamarin.Forms.Platform.Android.ViewRenderer}
{System.MissingMemberException}
Android.Gms.Maps.MapView.get_Map' not found
Any idea what is going on? It worked before the update. Any assistance would be appreciated.
Screen shots of my Nuget manager showing 2.3.3.193 as latest stable version.
Xamarin.Forms.Maps 2.3.3.193 requires Xamarin.GooglePlayServices.Maps version to be 29.0.0.1. Not 29.0.0.1 or higher!
Dependencies
From your screenshot, you have 42.1001.0
I'm in the same boat. Still got to use the nuget package built in march 2016!
Update
The issue is fixed in the latest stable version of Xamarin Forms 2.3.4.224.
Original Answer
Refer to https://bugzilla.xamarin.com/show_bug.cgi?id=52625 for discussion about this issue.
Google removed their java getMap method which had been obsoleted for some time (even in 29.0.0.1 you can see the equivalent Map property is marked obsolete). The Forms renderer uses the Map property (so the underlying java getMap method), which no longer exists in newer versions of play services, so crash occurs. The Forms renderer will need to change to use the GetMapAsync method.
Rob Lyndon (Bugzilla discussion) created the patch you could use: https://www.nuget.org/packages/XamarinForms.Maps.Android.TemporaryPatch
I couldn't use the patch directly from Nuget due to PCL profile missmatch, so I ended up doing the following:
Copy MapRenderer from the patch to your Android project. Make sure to adjust namespace
Extend Map in your PCL project
public class CustomMap : Xamarin.Forms.Maps.Map { }
Create custom renderer in Android project
[assembly: ExportRenderer(typeof(CustomMap), typeof(MapRenderer))]
namespace StanleySteemer.Nimbus.Mobile.Renderers
{
public class CustomMapRenderer : MapRenderer {}
}
Use CustomMap instead of Map in your View

System.MissingMethodException: Method 'Xamarin.Forms.Element.set_AutomationId' not found

When I am making a Barcode Scanner Using ZXing Nuget Package. As I am new to the Xamarin, When I run it in the Xamarin.forms. I am receiving that error. I have the updated version of Xamarin.The program shows me the runtime Exception as mentioned in the title.
This is more than likely due to the version of Xamarin.Forms that you are referencing. You need to make sure that your version of Xamarin.Forms is at least version 2.2, which has the AutomationId support.

Resources