Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No class found with @Document Annotation and attribute collectionName as: User, Android #53

Open
DzDev202020 opened this issue Apr 4, 2022 · 2 comments

Comments

@DzDev202020
Copy link

Hello there,
when I try to create collection this exception is thrown " No class found with @document Annotation and attribute collection Name as: User ", I am sure 100% my code and implementation are correct. If I use it in java code test it work 100%. The problem in reflection does not find the classes at runtime (samsung device). check the code below please:

this is my db init code:

String baseScanPackage = "com.myapp.chat.model";
  String base64EncodedKey = CryptoUtil.generate128BitKey(SomeSecretPassword, SomeUniqueSecreteSalt);
  ICipher cipher = new Default1Cipher(base64EncodedKey);
        jsonDBTemplate = new JsonDBTemplate(dbFilesLocation, baseScanPackage, cipher);

 if (!jsonDBTemplate.collectionExists(User.class))
            jsonDBTemplate.createCollection(User.class);

this is my User class code:

@Document(collection = "User", schemaVersion= "1.0")
public class User implements Serializable {

    @Id
    public String id;
   

    public User() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
   }

the problem is in reflection does not find classes at runtime.

@Hatzen
Copy link

Hatzen commented Apr 5, 2022

As you noticed in #42 there is currently No way to use this library on Android as the reflection lib is Not working.
Currently the best way to Go is to use a working library targeting Android Like Realm, Objectbox, Room, etc

@DzDev202020
Copy link
Author

@Hatzen I appreciate your reply, big thanks for you.
How other libraries work ?? which are using annotation, like Room for example your use @entity , @id .... , how did they used reflection or finding classes, Probably it is prebuild process or some thing like that is related to gradle?. actually I am low experience with gradle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants