Java.Lang.NoClassDefFoundError 在实施 Firebase 云消息传递时

Java.Lang.NoClassDefFoundError when implementing firebase cloud messaging

我正在使用 Firebase 云消息传递实现推送通知,为此我在我的 AndroidManifest.xml 文件中添加了这段代码

<!--FCM RECEIVER-->
<receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
  android:exported="false"/>
<receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
  android:exported="true"
  android:permission="com.google.android.c2dm.permission.SEND">
  
  <intent-filter>
    <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
    <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
    <category android:name="${applicationId}"/>
  </intent-filter>    
</receiver>
<!---FCM RECEIVER ENDS HERE-->

但是当我尝试 运行 应用程序时,它甚至在启动 activity

之前就抛出了应用程序
Java.Lang.NoClassDefFoundError: 'Failed resolution of: Lcom/google/android/datatransport/runtime/dagger/internal/Factory;'

顺便说一句,我为此功能安装了两个 NuGet 包:

  1. Xamarin.GooglePlayServices.Base
  2. Xamarin.Firebase.Messaging

我试过:

  1. 删除 bin 和 obj 文件夹并重新构建解决方案
  2. 将所有相同系列的 nugget 包更新到相同版本

安装 Xamarin.Google.Dagger 软件包为我解决了这个问题。

只需安装包 Xamarin.Google.Dagger。这应该够了吧。似乎它正在尝试寻找包裹,但没有找到。