当前位置: 首页 > 知识库问答 >
问题:

JAVAlang.RuntimeException:无法实例化服务com。桑里德。搭档JAVAMyFirebaseMessagingService

邵飞宇
2023-03-14

我正在使用Firebase消息,当我从Firebase控制台收到通知时,我的应用程序关闭,但出现此异常。有人能建议我应该怎么做吗?我正在与此问题斗争两个多小时了

我的Firebase Messagin版本是firebase_messaging:^6.0.16

我对firebaseMessaging的依赖性是implementation'com.google.firebase:firebase消息:20.2.3'

JAVAlang.RuntimeException:无法实例化服务com。桑里德。搭档JAVAMyFirebaseMessagingService:java。lang.ClassNotFoundException:在路径:DexPathList[[zip file”/system/framework/org.apache.http.legacy.boot.jar],zip文件“/data/app/com.samridh.partner-amekbtimigalfobi3aueg=/base.apk”]上找不到类“com.samridh.partner.java.MyFirebaseMessagingService”,nativeLibraryDirectories=[/data/app/com.samridh.partner-amekbtimigalfobi3aueg==/lib/arm64,/data/app/com.samridh.partner-amekbtimigalfobi3aueg==/base.apk!/lib/arm64-v8a,/system/lib64]]

我的Android清单。xml文件是

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.samriddh.partner">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
         <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <application
        android:name=".Application"
        android:label="samriddh partner"
        android:icon="@mipmap/launcher_icon">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
          <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
          </intent-filter>
          <intent-filter>
              <action android:name="android.intent.action.MAIN"/>
              <category android:name="android.intent.category.LAUNCHER"/>
          </intent-filter>
        </activity>

        <meta-data android:name="com.google.android.geo.API_KEY"
          android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>

        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
        
        <meta-data android:name="flutterEmbedding" android:value="2" />
        
        <service android:name=".service.MyFirebaseMessagingService"> </service>
        
        <service android:name=".java.MyFirebaseMessagingService" android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>    
        </service>    
    </application>
</manifest>

还有我的申请。kt文件是

package com.samriddh.partner

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService

class Application : FlutterApplication(), PluginRegistrantCallback {

    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    override fun registerWith(registry: PluginRegistry?) {
        io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
    }
}

共有3个答案

羊舌高爽
2023-03-14

检查顶部的包装是否正确。前任。

package com.samriddh.partner

如果你从一个例子中复制/粘贴(比如dummy me),它还有一些其他的包。

package com.google.firebase.quickstart.fcm.kotlin
龙永逸
2023-03-14

错误是告诉你Android找不到你声明的服务与完整的类名"com.samriddh.partner.java.MyFirebasMessagingService"。要么你从未添加过这个类,要么你告诉Android清单中的错误名称。

李奕
2023-03-14

公开上课为我解决了这个问题。

 类似资料:
  • 我的应用程序在真实设备或AndroidAVD上运行得非常完美,但由于AVD占用了大量内存,所以我安装了Genymotion。 现在,当应用程序启动时,应用程序崩溃,日志丢失 尝试了一些解决方案,都不管用 无法获取提供程序com.google.android.gms.measurement.AppDimurementContentProvider JAVAlang.RuntimeException:

  • 我在CentOS 7上安装了Cassandra版本3.9。在启动CassandraServer时,我遇到了如下错误: TRACE[MemtableFlushWriter:1]2017-05-15 04:25:49,735 LogTransaction.java:264-关闭事务日志[MC _ txn _ flush _ 3 F6 a46f 0-3961-11e 7-87 B4-0728 ea 39

  • 问题内容: 我正在尝试创建一个,所以我可以向JNDI请求一些企业Java Bean。JBoss运行正常,但是当我运行Java代码时,出现异常。 我正在运行JBoss 7.1 这是我的代码: 在启动JBoss服务器之后,我尝试运行Java代码,并得到以下异常: 可能是什么问题? 问题答案: InitialContext属性不适用于您使用的JBoss版本。使用JBoss 7,当您从远程客户端调用ejb

  • 我已经在Windows 10上安装了“数据斯塔克斯-ddc-64位-3.9.0.msi”,当我运行卡桑德拉CQL外壳时,我得到了这个错误。 连接错误:('无法连接到任何服务器',{'127.0.0.1':错误(10061,"尝试连接到[('127.0.0.1',9042)]。最后一个错误:无法进行连接,因为目标机器主动拒绝它")})

  • 买了一个阿里云服务器,必须要创建实例才可以使用吗?什么是阿里云服务器的实例呢?

  • 在运行< code>Cassandra命令,然后尝试在另一个命令提示符窗口中运行< code>cqlsh后,我收到了此错误。你能让我知道如何解决这个问题吗? 连接错误:('无法连接到任何服务器',{'127.0.0.1':错误(10061,"尝试连接到[('127.0.0.1',9042)]。最后一个错误:无法进行连接,因为目标机器主动拒绝它")})