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

Classes are generated, but not recognized in AS #187

Open
juliocbcotta opened this issue Jul 7, 2017 · 13 comments
Open

Classes are generated, but not recognized in AS #187

juliocbcotta opened this issue Jul 7, 2017 · 13 comments

Comments

@juliocbcotta
Copy link

juliocbcotta commented Jul 7, 2017

Hi, I am trying to use PaperParcel in my data class models, it does compile and run, but Android Studio is not indexing/recognizing the generated files.
Android Studio version 2.3.3
Kotlin version 1.1.3-2

My project is a multi-module project and I am using PaperParcel in one library module.
My project has multiple flavors and build types.
I see the generated code under
$library/build/generated/source/kapt/release/$packages_path

@grandstaish
Copy link
Owner

I've seen that with other libraries before, but I can't remember what fixed it 😓. Perhaps clear your Android Studio caches and restart? Doesn't sound like there's an issue with the library here though, just the IDE

@juliocbcotta
Copy link
Author

The IDE recognizes Dagger generated classes.... so I thought it could have something in PaperParcel. I did execute clean/build multiple times, but it's still happening. I will try the invalidate cache.

@grandstaish
Copy link
Owner

Weird, are the dagger files generated in the same location you mentioned? (i.e. $library/build/generated/source/kapt/release/$packages_path)

You're using kapt for both dagger and paperparcel right?

@juliocbcotta
Copy link
Author

Yes, they are in the same folder.
Yes, both use kapt.

@NikolaDespotoski
Copy link

NikolaDespotoski commented Jul 20, 2017

I'm experiencing the same issue. PaperParcelDataClassName.CREATOR is not found and dagger complains. Single module project, dagger 2.11, latest PP. Clearing caches doesnt resolve the issue, tho.

@grandstaish
Copy link
Owner

Any chance you have a sample project you could share?

@NikolaDespotoski
Copy link

NikolaDespotoski commented Jul 20, 2017

Actually, the sources are not even generated. Probably, previously generated PP data classes were cleaned and dagger tries to generate dependency code and if the dagger-annotated code has some reference to PP annotated classes, dagger fails.

If I set CREATOR to null

@PaperParcel
@Entity
data class User(
//fields omitted 
) : PaperParcelable {
    companion object {
        @JvmField var CREATOR = null//PaperParcelUser.CREATOR
    }
}

and run /gradlew clean assembleDebug, everything is ok. There is no compilation error regarding PPUser.CREATOR (it is generated at this point).

My dependency graph looks like this (referenced): PP annotated models -> modelsDao(Room) -> Repository -> ViewModels ->Fragments/Activities.

I commented on this issue, under assumption that if the sources cant be imported, they dont exist. If you want me I can open new issue and move all this there.

@mxia
Copy link

mxia commented Oct 17, 2017

Same issue here, with Android Studio 3.0 beta 7, kotlin 1.1.4 and parperparcel 2.0.4. The PaperParcelData class isn't generated.

@grandstaish
Copy link
Owner

Could you share your build.gradle + annotated class? Also, is the annotated class in the same module as where you define the processor in build.gradle?

@mxia
Copy link

mxia commented Oct 17, 2017

I was just able to resolve the issue by following what @NikolaDespotoski said: set CREATOR to null first, compiled the source from Android Studio and saw the generated code in build folder, and then updated the source code to "CREATOR = PaperParcelDataClass.CREATOR". So I'm good for now.

@grandstaish
Copy link
Owner

Super weird. Is that using instant run, or something else that might not trigger the annotation processor to run? Sometimes you might need to use Android Studio's Build -> Rebuild Project menu item to ensure all annotation processors are run. Not sure if that's the issue though

@mxia
Copy link

mxia commented Oct 17, 2017

The project was building and running fine with paperparcel 1.0.1, and I was migrating to 2.x, so thought it might be a caching issue and tried 'Clean Project' + 'Rebuild Project', as well as invalidating the cache and restarting AS, but none was helping.

@justcuri0us
Copy link

I know this is two years old now, but I discovered it while trying to solve the same problem this week.

The solution that worked for me was to change the filename (but not the class name) so that it was shorter. I suspect that there is a inherent limit to the length of the path to the file which is causing the problem.

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

5 participants