这是我的类(无论如何,它的第一部分)。
public class FirebaseService extends FirebaseMessagingService implements TobCommInterface
{
private static final int TICK_RATE_ALERT_SERVICE = 100;
private static final int TIMEOUT = 5000;
private static final int MESSAGE_BUFFER_SIZE = 10240;
private static final String TAG = "LAUNCH_ATTACK_ALERTS";
private static final String CHANNEL_ID = "default";
private static final long[] VIBRATE = new long[]{ 0, 2000, 400, 400, 400, 400, 400, 400 };
private Context context;
private enum State
{
CONNECT,
CONNECTING,
PROCESS
}
private Socket socket;
private InputStream in;
private OutputStream out;
private ShortDelay dlyTimeout = new ShortDelay();
private long oIdleTime;
private TobComm tobComm;
private State state = State.CONNECT;
private static int lDebugInstance = 0;
private ScheduledExecutorService seCommsService;
public FirebaseService(Context context)
{
this.context = context;
}
这是我在日志中遇到的错误:
java.lang.RuntimeException: Unable to create service com.apps.fast.launch.notifications.FirebaseService: java.lang.InstantiationException: java.lang.Class<com.apps.fast.launch.notifications.FirebaseService> has no zero argument constructor
我听说AndroidManifest.xml也可能涉及此错误,所以这里是其中的FirebaseMessaging条目:
<service
android:name=".notifications.FirebaseService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
我远不是这方面的专家,目前我只是想让Firebase消息传递为我的游戏工作。当我打开应用程序时,它立即崩溃并出现此错误。当我重新启动应用程序时,它不会崩溃。
删除:
public FirebaseService(Context context)
{
this.context = context;
}
那是你的问题。你不需要它;Service
是Context
.