3

I'm trying to build my project, but when I do, I get this error: "error: package com.google.firebase.messaging does not exist", along with other 4 errors of the same kind.

    package md5f64326b4609986d97810cf2ced03c9ce;


public class MyFirebaseMessagingService
extends com.google.firebase.messaging.FirebaseMessagingService
implements
    mono.android.IGCUserPeer
{
/** @hide */
public static final String __md_methods;
static {
    __md_methods = 
        "n_onMessageReceived(Lcom/google/firebase/messaging/RemoteMessage;)V:GetOnMessageReceived_Lcom_google_firebase_messaging_RemoteMessage_Handler\n" +
        "";
    mono.android.Runtime.register ("FCMClient.MyFirebaseMessagingService, LimBands.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", MyFirebaseMessagingService.class, __md_methods);
}


public MyFirebaseMessagingService ()
{
    super ();
    if (getClass () == MyFirebaseMessagingService.class)
        mono.android.TypeManager.Activate ("FCMClient.MyFirebaseMessagingService, LimBands.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "", this, new java.lang.Object[] {  });
}


public void onMessageReceived (com.google.firebase.messaging.RemoteMessage p0)
{
    n_onMessageReceived (p0);
}

private native void n_onMessageReceived (com.google.firebase.messaging.RemoteMessage p0);

private java.util.ArrayList refList;
public void monodroidAddReference (java.lang.Object obj)
{
    if (refList == null)
        refList = new java.util.ArrayList ();
    refList.add (obj);
}

public void monodroidClearReferences ()
{
    if (refList != null)
        refList.clear ();
}
}

This is my whole file, it is on the obj folder. I already tried deleting the bin/obj folders, manually deleting and reinstalling all nuget packages, changing nuget package versions (downgrading and upgrading), but nothing seems to work.

I even compared some files with another solution that works the same way, and I found no differences.

FreakyAli
  • 13,349
  • 3
  • 23
  • 63

2 Answers2

8

UPDATE

It seems updating to the latest version of all the below packages and updating Xamarin.Build.Download to 0.4.11 also solves the issue.


The problem you are facing right now is a common problem to which a proper solution has not been provided by Xamarin so there is this workaround I made up the last time I faced this problem.

If you are using both Google maps and Firebase Cloud Messaging the following are the steps you need to take:

  • Check the versions of the following DLL's in your references and upgrade or downgrade your references to match these versions:

Xamarin.Firebase.Common- 42.1021.1

Xamarin.Firebase.lid- 42.1021.1

Xamarin.Firebase.Messaging- 42.1021.1

Xamarin.GooglePlayServices.Base- 42.1021.1

Xamarin.GooglePlayServices.Basement- 42.1021.1

Xamarin.GooglePlayServices.GCM- 42.1021.1

Xamarin.GooglePlayServices.lid- 42.1021.1

Xamarin.GooglePlayServices.Location- 42.1021.1

Xamarin.GooglePlayServices.Maps- 42.1021.1

Xamarin.GooglePlayServices.Tasks- 42.1021.1

  • Check the current version of your xamarin build DLL in case it is above 0.4.2 downgrade it to 0.4.2

Xamarin.Build.Download- 0.4.2

  • Clean and Build your solution in case the problem still persists delete the bin and obj folders and then clean build your project.

In case the problem still persists kindly comment so I can follow up.

FreakyAli
  • 13,349
  • 3
  • 23
  • 63
  • Thank you so much for your help! I already fixed the problem by creating a different solution and adding every single file manually, as well as changing every namespace and everything else to match the new solution. It is working fine now. – Mauricio Cárdenas Feb 22 '18 at 18:22
  • @G.hakim there are no private messages in stackoverflow, so I’ll appeal to you through a comment about your article "helper for converting a Xamarin.Forms ImageSource", https://stackoverflow.com/questions/54764681/how-to-convert-imagesource-to-bitmap-for-cross-platform-projectxamarin – StriBog Mar 11 '19 at 16:57
3

If you've cleared the NuGet cache, deleted the bin and obj files, and rebuilt the solution, and your Xamarin.Build.Download and Xamarin.Firebase.XXX packages are up to date, and the problem still persists, you can, as a last resort, use

update-package -reinstall Xamarin.Firebase.Messaging

For some reason, this worked for me.

Rob Lyndon
  • 12,089
  • 5
  • 49
  • 74
  • This also worked for me without clearing out caches / deleting intermediate files. I wish I knew *why*, but at least it works... – adam_0 Jul 23 '19 at 22:32