0

I am trying to disable ProgUard because it blocks my constructors on the Activities. This is the constructor:

public ChatFragmentAdapter(Context context, List<Users> user, boolean isChat) {
    this.context = context;
    this.user = user;
    this.isChat = isChat;
}

And this is the error that shows:

com.google.firebase.database.DatabaseException: Class com.example.selfcial.Models.Chat does not define a no-argument constructor. If you are using ProGuard, make sure these constructors are not stripped.
        at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.deserialize(CustomClassMapper.java:570)
        at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.deserialize(CustomClassMapper.java:563)
        at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertBean(CustomClassMapper.java:433)
        at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToClass(CustomClassMapper.java:232)
        at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertToCustomClass(CustomClassMapper.java:80)
        at com.google.firebase.database.DataSnapshot.getValue(DataSnapshot.java:203)
        at com.example.selfcial.Adapters.ChatFragmentAdapter$2.onDataChange(ChatFragmentAdapter.java:154)
        at com.google.firebase.database.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:75)
        at com.google.firebase.database.core.view.DataEvent.fire(DataEvent.java:63)
        at com.google.firebase.database.core.view.EventRaiser$1.run(EventRaiser.java:55)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7562)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

I tried to add useProguard false inside Gradle, but nothing changed. What can I do to solve this annoying error? Should I delete the whole file of ProGuard?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Achisyg
  • 31
  • 6
  • Does this answer your question? [users does not define no argument constructor](https://stackoverflow.com/questions/47706601/users-does-not-define-no-argument-constructor) – Koenigsberg Mar 03 '21 at 23:06
  • What do you mean by "blocks my constructors on the Activities"? Why did you paste a constructor for something that is neither an Activity nor the class in the error message? Does the class in the error message have a no-argument constructor? – Ryan M Mar 04 '21 at 01:53
  • @RyanM I mean that when I run the app it crashes because of the above error. The class in the error message has a no-argument constructor but it still shows the error. – Achisyg Mar 04 '21 at 10:08
  • @Koenigsberg I tried this one but nothing changed.. – Achisyg Mar 04 '21 at 10:09

1 Answers1

1

It seems like you’re on the wrong path. Even though the exception message mentions ProGuard, the problem is explained in the first part of the message: Class com.example.selfcial.Models.Chat does not define a no-argument constructor

Adding a no-arg constructor to your class Chat should solve it:

public Chat() {}
Matthias Ronge
  • 9,403
  • 7
  • 47
  • 63