-
Notifications
You must be signed in to change notification settings - Fork 42
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
Factory not generated sometimes #58
Comments
Actually it's strange. When just cloning the repo and running the test from command line, everything works fine. But if I then compile and launch the app using Android Studio and then call |
It works just fine for me, weird. |
These steps fail 100% of the time for me.
|
It seems to be an issue regarding KAPT, if I clean and build again it works just fine. |
Do you have any idea what is going on there? I can't find other words for reporting it upstream other than "not working sometimes" ;) |
I ask myself why that whole ceremony is necessary at all. I mean by looking at FactoryProcessingStep.kt it seems like there can be only a single factory at all. So why not just generate a factory? It feels strange to create a class, annotate it with something and then let that class extend something that is based upon the fact that it is annotated. That's a circular chain. |
It keeps generated code out of the public API. Same as Dagger, AutoValue,
etc.
…On Fri, Feb 9, 2018 at 11:41 AM Paul Woitaschek ***@***.***> wrote:
I ask myself why that whole ceremony is necessary at all.
I mean by looking at FactoryProcessingStep.kt it seems like there can be
only a single factory at all. So why not just generate a factory?
It feels strange to create a class, annotate it with something and then
let that class extend something that is based upon the fact that it is
annotated. That's a circular chain.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#58 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEdOc3brs_sxXdJJqesKSn9EnjpfQks5tTHU8gaJpZM4R_8D2>
.
|
Having same problem. Running the app is fine but running unit test or UI test will cause the factory not to be generated. I got this error in my terminal
|
Could you check the following things for me:
|
It seems like the factory is not generated under build folder, the jsonadpater each object is created tho. EDIT: Seems to be working fine with 0.3.0. I'll be sticking to it for a while |
I wonder if it has to do with the fact that you subclass something that doesn't exist. But it should still run the code. |
Btw the generation of the adapters is completely reliable. As a workaround I just copied the generated factory and manually add new adapters by hand. @vincent-paing Do you also have the kotshi stuff in a library module? |
Yes, I'm having kotshi stuffs in my library module(data module as in the path). Trying to build an app with clean architecture so I'm separating it from my actual app module. |
Seeing this too. Switching to using delegation doesn't seem to work either.
…On Wed, Feb 14, 2018 at 9:34 AM Aung Kyaw Paing ***@***.***> wrote:
Yes, I'm having kotshi stuffs in my library module(data module as in the
path). Trying to build an app with clean architecture so I'm separating it
from my actual app module.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#58 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEW4p-TZWaVLa4JPRMvvXlL9frJCdks5tUu7tgaJpZM4R_8D2>
.
|
Hmm, ok. So this seems to be a universal problem them, we could just revert to the previous way of implementing the factory but I would want to understand why it's happening. It feels like a bug in kapt and not Kotshi. |
I wonder if it's because of the bump to Kotlin 1.2.21, only thing I can think of that might cause this. |
I was using 1.2.30 EAPs with 0.3.0 and didn't have the problem. Only upon
bumping to 1.0.0 did it start occurring.
…On Wed, Feb 14, 2018 at 9:52 AM Nicklas Ansman Giertz < ***@***.***> wrote:
I wonder if it's because of the bump to Kotlin 1.2.21, only thing I can
think of that might cause this.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#58 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEYP8Nkwzx-XBeAg2d_bKZoqmPYdSks5tUvMvgaJpZM4R_8D2>
.
|
Hmm, ok. Well I don't really know what could cause this: 0.3.0...1.0.0 |
My guess is that the generated reference moved from being inside of a
method body where it didn't participate in stub generation to part of the
hierarchy where stub generation can't complete because of the cyclic
dependency between stub generation needed kapt to run to generate the base
class and kapt needing the stubs to generate the base class.
…On Wed, Feb 14, 2018 at 9:56 AM Nicklas Ansman Giertz < ***@***.***> wrote:
Hmm, ok. Well I don't really know what could cause this: 0.3.0...1.0.0
<0.3.0...1.0.0>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#58 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEZKyybS2elawuH4wIQTL8qWQi4Vtks5tUvQggaJpZM4R_8D2>
.
|
I'll add a PR that allows both the new and old way of implementing the factory. Let's see if that helps. |
Please try the snapshot @KotshiJsonAdapterFactory
abstract class MyFactory : JsonAdapter.Factory {
companion object {
@JvmField
val INSTANCE: MyFactory = KotshiMyFactory()
}
} Let me know if the problem persists. |
Works fine here. No problems running back and forth from CLI to AS.
…On Fri, Feb 16, 2018 at 11:37 AM Nicklas Ansman Giertz < ***@***.***> wrote:
Please try the snapshot 1.1.0-20180215.183751-6, with that you can use
the old way of implementing the factory:
@KotshiJsonAdapterFactory
abstract class MyFactory : JsonAdapter.Factory {
companion object {
@JvmField
val INSTANCE: MyFactory = KotshiMyFactory()
}
}
Let me know if the problem persists.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#58 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEU9opl4-YabBtjEzM7kRrlCfYfP1ks5tVa68gaJpZM4R_8D2>
.
|
Ok, I've implemented so that the pre 1.0 way is allowed too. I'll try to file an issue on youtrack and fix the root issue. |
FYI, the issue has been fixed in the latest version of Kotshi and the preferred way to declare you factory is as an |
When running my app which uses kotshi in a module from android studio, everything is fine.
However when I run it from commandline in tests, it fails because the adapter factory is not generated.
I made a sample probject:
https://github.com/PaulWoitaschek/KotshiFactoryBug
which fails when running
./gradlew test
The text was updated successfully, but these errors were encountered: