kenglxn / QRGen

a simple QRCode generation api for java built on top ZXING
http://glxn.net/2012/03/10/qrgen-a-small-wrapper-on-top-of-zxing-for-generating-qrcodes-in-java
1.49k stars 299 forks source link

Unable to extend Schema for Custom Schema #108

Closed nflynn-rm closed 5 years ago

nflynn-rm commented 6 years ago

Hi,

I am trying to create a custom Schema in my own project and I am unable to do so due to the following error:

Schema() is not public in Schema; cannot be accessed from outside package

Is there a way around this that I am not seeing or could someone point me in the right direction, please?

kenglxn commented 6 years ago

A bit hard to tell what's wrong from that message alone, but it sounds like the compiler is telling you to add a no-args public constructor. What does your implementation look like?

you can take a look at one of the Schema implementations in QRGen for example SMS https://github.com/kenglxn/QRGen/blob/master/core/src/main/java/net/glxn/qrgen/core/scheme/SMS.java

nflynn-rm commented 6 years ago

Sorry I should have posted an example.

public class CustomSchema extends Schema {

    CustomSchema() {
        super();
    }

    @Override
    public Schema parseSchema(String code) {
        return null;
    }

    @Override
    public String generateString() {
        return null;
    }
}

The compiler is complaining about the super() call, saying that:

Schema() is not public in "net.glxn.qrgen.core.scheme.Schema". Cannot be accessed from outside package
kenglxn commented 6 years ago

Ok. Sounds like maybe you are hitting a bug that was fixed a while back. Looks like I have forgotten to make a new release with the bugfix. Until I do, you can use the latest master from jitpack. Should solve the issue for you: https://jitpack.io/#kenglxn/QRGen/6e52800b25, bugfix: https://github.com/kenglxn/QRGen/pull/105

nflynn-rm commented 6 years ago

Great, that seems to have solved the problem.

Thanks for your help!

kenglxn commented 6 years ago

reopening this. will close once release is made