Search code examples
androidandroid-studiorealm

Android error during build - "default public constructor with no argument must be declared". What's the cause?


Android studio returned an error during build, even after running Clean, and rebuilding:

A default public constructor with no argument must be declared if a custom constructor is declared.

I could not find a line number, nor a file referenced. I have no idea what causes this, as there's no indication from the build where or what the cause of this is.


Solution

  • If you have a custom constructor like this

    public class Doge extends RealmObject {
         public Doge(String name) {
           ... 
    

    Then you must also have a default constructor with no additional parameters.

    public Doge() {
        // default values possible since 2.0.2
    }