I'm attempting to integrate the Localytics SDK (via their Xamarin component) into my Xamarin Android app. It compiles in Debug mode, however if I switch to a Release build then it errors on compile:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Error executing task LinkAssemblies: error XA2006: Could not resolve reference to 'Android.Gms.Gcm.Iid.InstanceIDListenerService' (defined in assembly 'LocalyticsXamarin.Android, Version=4.2.0.29760, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.GooglePlayServices.Gcm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. (com.rpr.mobile.droid)
If I switch the Linker Behavior from Link SDK assemblies only to Don't link then it compiles fine, however this isn't an option because then the apk is too large. If I switch back to Link SDK assemblies only and add "LocalyticsXamarin.Android" to the Ignore assemblies list, it still gives the same compile error.
This error seems to imply a versioning mismatch in Google Play Services between my app and the Localytics Xamarin wrapper, however they sent me an updated version of their wrapper that uses the latest version (42.1001.0) and I've confirmed that it matches with our app. Furthermore, their own sample Android project compiles fine. I've combed through every setting in their sample Android project and changed it to match mine, and still theirs compiles and mine doesn't.
Here is packages.config in my Android project:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="modernhttpclient" version="2.4.2" targetFramework="MonoAndroid60" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="MonoAndroid60" />
<package id="Rx-Core" version="2.2.5" targetFramework="monoandroid70" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="monoandroid70" />
<package id="Rx-Linq" version="2.2.5" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Compat" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Core.UI" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Core.Utils" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Fragment" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Media.Compat" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v13" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v4" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="25.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Build.Download" version="0.4.3" targetFramework="monoandroid70" />
<package id="Xamarin.Firebase.Analytics" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.Firebase.Analytics.Impl" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.Firebase.Common" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.Firebase.Iid" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Analytics" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Analytics.Impl" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Base" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Basement" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Gcm" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Iid" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Location" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Maps" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.TagManager.V4.Impl" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Tasks" version="42.1001.0" targetFramework="monoandroid70" />
</packages>
And here is packages.config for the sample Localytics project that works:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Android.Support.Compat" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.Core.UI" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.Core.Utils" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.Design" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.Fragment" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.Media.Compat" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.Transition" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.v4" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.v7.CardView" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.v7.Palette" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="25.1.1" targetFramework="MonoAndroid70" />
<package id="Xamarin.Build.Download" version="0.4.3" targetFramework="MonoAndroid70" />
<package id="Xamarin.Forms" version="2.3.3.193" targetFramework="MonoAndroid70" />
<package id="Xamarin.GooglePlayServices.Base" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Basement" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Clearcut" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Gass" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Gcm" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Iid" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Tasks" version="42.1001.0" targetFramework="monoandroid70" />
</packages>
To reproduce the issue...
Here is the Localytics SDK Xamarin wrapper latest code, which builds just fine. You'll want to take the .xam file and install it to Xamarin Studio using Xamarin-Component.
Here is a slimmed down version of my Android project code.
I apologize for the size of my project, I removed all of the code and resources but it's still big because of the Components and Packages, which I didn't want to remove since they're relevant to the issue. You'll want to open the RPR Mobile - Android.sln solution, change to Release-Prod, then try to build and you'll see the error.
Any ideas?
The component that ships with this PATCHED
version does not seem to be updated to include the references you need such as Xamarin.GooglePlayServices.Iid
.
You will need to most likely remake this component or have the vendor do so for you. It seems like there's a caching issue here with regards to what final .dll
is being added to your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With