Нет метода stati c intoSet в Firebase | ошибка при попытке реализовать базу данных firebase и уведомление pu sh - PullRequest
1 голос
/ 25 января 2020

Я использую базу данных firebase и уведомление firebase pu sh, когда я запускаю свое приложение, оно вылетает с ошибкой firebase

Это ошибка:

 java.lang.NoSuchMethodError: No static method intoSet(Ljava/lang/Object;Ljava/lang/Class;)Lcom/google/firebase/components/Component;in class Lcom/google/firebase/components/Component;or its super classes (declaration of 'com.google.firebase.components.Component' appears in /data/app/com.shadow.recipeworld-1/base.apk)
        at com.google.firebase.platforminfo.LibraryVersionComponent.create(com.google.firebase:firebase-common@@19.3.0:25)
        at com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar.getComponents(com.google.android.gms:play-services-measurement-api@@17.2.2:10)
        at com.google.firebase.components.zzf.<init>(com.google.firebase:firebase-common@@16.0.2:52)
        at com.google.firebase.FirebaseApp.<init>(com.google.firebase:firebase-common@@16.0.2:539)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.2:355)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.2:324)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.2:310)
        at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@16.0.2:53)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@16.0.2:47)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5173)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4768)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4708)
        at android.app.ActivityThread.-wrap1(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1406)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5438)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:762)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)

Ниже приведено содержимое в gradle:

    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'com.google.firebase:firebase-database:19.2.0'
    implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'com.firebase:firebase-client-android:2.5.2'

Мой сервис уведомлений:

    public class GeneralNotificationService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        Global.showNotification(getBaseContext(),remoteMessage.getNotification().getTitle(),remoteMessage.getNotification().getBody());


    }
}

Моя функция уведомлений:

    public static void showNotification( Context c,String title,String message)
    {

        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O)
        {
            NotificationChannel channel =new NotificationChannel("GeneralNotification","GeneralNotification", NotificationManager.IMPORTANCE_DEFAULT);
            NotificationManager manager=c.getSystemService(NotificationManager.class);
            manager.createNotificationChannel(channel);

            Notification.Builder builder=new Notification.Builder(c,"GeneralNotification")
                    .setContentTitle(title)
                    .setSmallIcon(R.drawable.ic_launcher_background)
                    .setAutoCancel(true)
                    .setContentText(message);
            manager.notify(1,builder.build());

        }
        else
        {

            NotificationCompat.Builder builder=new NotificationCompat.Builder(c,"GeneralNotification")
                    .setContentTitle(title)
                    .setSmallIcon(R.drawable.ic_launcher_background)
                    .setAutoCancel(true)
                    .setContentText(message);
            NotificationManagerCompat manager=NotificationManagerCompat.from(c);
            manager.notify(1,builder.build());
        }



    }

Любая помощь будет оценена!

1 Ответ

0 голосов
/ 25 января 2020

Удалите следующую зависимость:

implementation 'com.firebase:firebase-client-android:2.5.2'

Это старая библиотека Firebase, которая больше не поддерживается.

...