(ProGuard) Looking for a constructor that does not exist
stoyicker opened this issue · 7 comments
With ProGuard enabled, I get this error:
Warning: MyAppStateReducer$Builder: can't find referenced method 'MyAppStateReducer(com.yheriatovych.reductor.Reducer,MyAppStateReducer$1)' in program class MyAppStateReducer
which I find interesting because my code for MyAppStateReducer is just a dummy and it does not have a sub-class nor a constructor taking two parameters:
class AppStateReducer(val peopleListReducer: Reducer<List<Person>>): Reducer<AppState> {
override fun reduce(state: AppState, action: Action): AppState {
val initialPersonList = state.personList()
val reducedPersonList = peopleListReducer.reduce(initialPersonList, action)
return if (initialPersonList == reducedPersonList) {
state
} else {
AppState.createFrom(reducedPersonList)
}
}
}
It compiles without ProGuard though which I don't undestand because although a Builder class is created, there is still no two-parameter constructor.
Hi, interesting case.
It should not affect proguard as most of the generated code is used directly (without reflection).
However as I can see maybe there is some interesting combination of Kotlin, proguard, generated code.
I didn't heavily test Reductor on how it works with Kotlin yet, but probably I should.
Can you create a minimal project to reproduce this issue?
Unfortunately I have this setup at work and can't share the source, but I will create an mwe as soon as I have time home.
Thanks, that would be great!
I will try to reproduce it by myself.
Ok, Now I see what the issue is about.
The problem is that you defined the class AppStateReducer
which is also generated.
As you annotated your state with @CombinedState
that means that reductor will generate reducer that delegates actions to sub reducers.
And as I can see you are doing this manually in AppStateReducer
So in your case, you can either
- Remove your
AppStateReducer
, as generated one doing exactly the same. - Remove annotation
@CombinedState
fromAppState
, so you will not generated reducer for this class. - Rename your reducer, so they will not conflict.
That makes a lot of sense, thanks.