Coder Social home page Coder Social logo

Factory not generated sometimes about kotshi HOT 24 CLOSED

ansman avatar ansman commented on May 30, 2024 1
Factory not generated sometimes

from kotshi.

Comments (24)

ansman avatar ansman commented on May 30, 2024 1

Could you check the following things for me:

  1. Is the factory actually generated (if you look in the build folder)?
  2. Does the same issue happen with 0.3.0?

from kotshi.

ansman avatar ansman commented on May 30, 2024 1

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.

from kotshi.

PaulWoitaschek avatar PaulWoitaschek commented on May 30, 2024

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 ./gradlew test and then launch it using Android Studio again, it fails.

from kotshi.

ansman avatar ansman commented on May 30, 2024

It works just fine for me, weird.

from kotshi.

PaulWoitaschek avatar PaulWoitaschek commented on May 30, 2024

These steps fail 100% of the time for me.

  1. Git Clone
  2. Add it in android studio
  3. Press run
  4. Run ./gradlew test in the terminal tab

from kotshi.

ansman avatar ansman commented on May 30, 2024

It seems to be an issue regarding KAPT, if I clean and build again it works just fine.

from kotshi.

PaulWoitaschek avatar PaulWoitaschek commented on May 30, 2024

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" ;)

from kotshi.

PaulWoitaschek avatar PaulWoitaschek commented on May 30, 2024

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.

from kotshi.

JakeWharton avatar JakeWharton commented on May 30, 2024

from kotshi.

vincent-paing avatar vincent-paing commented on May 30, 2024

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

e: /Users/vincent/AndroidStudioProjects/{Project NAME}/data/build/tmp/kapt3/stubs/debug/mm/pulse/prices/data/network/AppJsonAdapterFactory.java:10: error: cannot find symbol
public final class AppJsonAdapterFactory extends mm.pulse.prices.data.network.KotshiAppJsonAdapterFactory {
                                                                                     ^
  symbol:   class KotshAppJsonAdapterFactory
  location: package mm.pulse.prices.data.network

FAILURE: Build failed with an exception.

from kotshi.

vincent-paing avatar vincent-paing commented on May 30, 2024

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

from kotshi.

ansman avatar ansman commented on May 30, 2024

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.

from kotshi.

PaulWoitaschek avatar PaulWoitaschek commented on May 30, 2024

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?

from kotshi.

vincent-paing avatar vincent-paing commented on May 30, 2024

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.

from kotshi.

JakeWharton avatar JakeWharton commented on May 30, 2024

from kotshi.

ansman avatar ansman commented on May 30, 2024

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.

from kotshi.

ansman avatar ansman commented on May 30, 2024

I wonder if it's because of the bump to Kotlin 1.2.21, only thing I can think of that might cause this.

from kotshi.

JakeWharton avatar JakeWharton commented on May 30, 2024

from kotshi.

ansman avatar ansman commented on May 30, 2024

Hmm, ok. Well I don't really know what could cause this: 0.3.0...1.0.0

from kotshi.

JakeWharton avatar JakeWharton commented on May 30, 2024

from kotshi.

ansman avatar ansman commented on May 30, 2024

I'll add a PR that allows both the new and old way of implementing the factory. Let's see if that helps.

from kotshi.

ansman avatar ansman commented on May 30, 2024

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.

from kotshi.

JakeWharton avatar JakeWharton commented on May 30, 2024

from kotshi.

ansman avatar ansman commented on May 30, 2024

FYI, the issue has been fixed in the latest version of Kotshi and the preferred way to declare you factory is as an object that subclasses the generated factory

from kotshi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.