koin version implementation "org.koin:koin-androidx-scope:2.0.1"
debug no minified version work fine, but after application minified when I open fragment with inject presenter app crashed...
stacktrace with proguard retrace
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:557)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
... 1 more
Caused by: e.a.b.c.e: No definition found for 'c.d.a.c.a.f' has been found. Check your module definitions.
at org.koin.core.scope.Scope.findDefinition(SourceFile:20)
at org.koin.core.scope.Scope.resolveInstance(SourceFile:12)
get
at package.AnalyticsFragment$$special$$inlined$inject$1.invoke(SourceFile:4)
at kotlin.SynchronizedLazyImpl.getValue(SourceFile:6)
at package.AnalyticsFragment.getPresenter(Unknown Source:7)
initResultGraph
at package.AnalyticsFragment.onViewCreated(SourceFile:67)
at androidx.fragment.app.FragmentManagerImpl.moveToState(SourceFile:270)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(SourceFile:18)
at androidx.fragment.app.FragmentManagerImpl.moveToState(SourceFile:368)
at androidx.fragment.app.BackStackRecord.executeOps(SourceFile:27)
at androidx.fragment.app.FragmentManagerImpl.executeOps(SourceFile:524)
executeOpsTogether
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(SourceFile:37)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(SourceFile:4)
at androidx.fragment.app.FragmentManagerImpl$1.run(SourceFile:1)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6806)
... 3 more
in application
override fun onCreate() {
super.onCreate()
val cicerone = Cicerone.create()
val mainModule: Module = module {
single {
Room.databaseBuilder(androidApplication(), RoomDataBase::class.java, "game_db")
.build()
}
single(createdAtStart = false) { get<RoomDataBase>().gameDao() }
single { cicerone.navigatorHolder }
single { cicerone.router }
single { SharedPreferences(get()) }
single { Repository(get()) }
factory { (view: AnalyticsFragmentContract.View) ->
AnalyticsPresenter(
view = view,
repository = get()
)
}
}
startKoin {
androidContext(this@App)
modules(listOf(mainModule))
}
}
in fragment presenter call code
class AnalyticsFragment : BaseFragment(), AnalyticsFragmentContract.View {
private val presenter: AnalyticsFragmentContract.Presenter by inject { parametersOf(this) }
what rules need add to proguard.txt?
rules in https://insert-koin.io/docs/2.0/quick-references/experimental-features/#proguard-rule not working
-keepnames class android.arch.lifecycle.ViewModel
-keepclassmembers public class * extends android.arch.lifecycle.ViewModel { public <init>(...); }
-keepclassmembers class com.lebao.app.domain.** { public <init>(...); }
-keepclassmembers class * { public <init>(...); }
From the exception, it looks like you are using AndroidX. If that's the case, then maybe it could work by changing android.arch.lifecycle.ViewModel to androidx.lifecycle.ViewModel in the proguard rules.
anything resolved? @sereja93
I'm having the same issue, only this proguard rule made it work:
-keepclassmembers class * { public <init>(...); }
Most helpful comment
anything resolved? @sereja93