skydoves / PreferenceRoom

:truck: Android processing library for managing SharedPreferences persistence efficiently and structurally.
Apache License 2.0
378 stars 26 forks source link

Code is not generated #10

Closed ahmadmssm closed 5 years ago

skydoves commented 5 years ago

@ahmadmssm Hello! Could you explain more specifically about it? Is the code not generated from the clone of this repository?

ahmadmssm commented 5 years ago

Thanks for you swift response. I created this class after adding the library dependency `@PreferenceEntity public class SharedPreference {

// Share preference keys
@interface Keys {
    String USER = "user";
}

@KeyName(name = "user")
@TypeConverter(converter = SharedPreferenceTypeConverter.class)
protected User user;

}` and didi a clean and build however the code did not genertaed

skydoves commented 5 years ago

@ahmadmssm You should remove below codes.

@interface Keys {
    String USER = "user";
}

Thank you!

ahmadmssm commented 5 years ago

Still not solved although i removed the code you mentioned

skydoves commented 5 years ago

@ahmadmssm Hello, this is the instruction of how to create a base structure. I think you already create a class User.

Firstable, you should create an UserEntity.class entity using @PreferenceEntity annotation.

@PreferenceEntity(name = "UserEntity")
public class UserEntity {
    @KeyName(name = "user")
    @TypeConverter(converter = SharedPreferenceTypeConverter.class)
    protected User user;
}

Second, build project. Build -> Rebuild Project on Android Studio IDE.

After build, this library will generates automatically Preference_UserEntity.class.

You can reference this demo project. Thank you for your issue!

albert0m commented 5 years ago

I'm having the same problem. This used to work, until I had to reimport the project in Studio, and now I can't seem to have the class generated. I migrated from 1.1.3 to 1.1.7, just to be sure. This is my class:

@PreferenceEntity( "MySettings")
public class MySettings {

    @KeyName("lightMode")
    protected final boolean lightMode = false;

    @KeyName("microphoneService")
    protected final boolean microphoneService = false;

    @KeyName("votingService")
    protected final boolean votingService = false;

    @PreferenceFunction("lightMode")
    public boolean putLightModeFunction(boolean lightMode) {
        return lightMode;
    }

    @PreferenceFunction("microphoneService")
    public boolean putMicServiceFunction(boolean microphoneService) {
        return microphoneService;
    }

    @PreferenceFunction("votingService")
    public boolean putVotingServiceFunction(boolean votingService) {
        return votingService;
    }

}

class is not generated. Everytime I run a Rebuild, it abruptly stops saying that it can't find the generate class

error: cannot find symbol class Preference_MySettings

skydoves commented 5 years ago

@marconealberto Could you build this demo project? If the demo project would generate classes, I think the annotationProcessor has some problem.

annotationProcessor "com.github.skydoves:preferenceroom-processor:1.1.7"
albert0m commented 5 years ago

just tried the demo project and it's not working either

error: cannot find symbol class PreferenceComponent_AppComponent

but I guess it's something with the import of the project. I'm sure the demo project works, it's just that something broke on my local machine in the last few weeks and I don't understand what. Do you have any pointers? is there a way to mock the creation of the files to check if there's something else that doesn't let me create the classes?

skydoves commented 5 years ago

@albert0m I think it has code generating error over the 4.0.0 Gradle version. Because of the javaPoet library has the same issue. I released downgraded version 1.1.8. And I checked it working well on this simple demo project. Thank you for your issue!