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

Need proguard rule when using androidx ViewModel #180

Closed
edipo2s opened this issue Jul 26, 2018 · 3 comments
Closed

Need proguard rule when using androidx ViewModel #180

edipo2s opened this issue Jul 26, 2018 · 3 comments
Assignees
Labels
android status:checking currently in analysis - discussion or need more detailed specs type:issue
Milestone

Comments

@edipo2s
Copy link

edipo2s commented Jul 26, 2018

Describe the bug
When using androidx ViewModel, after set minifyEnabled true, my app crashes with message:
No compatible definition found for type 'com.app.b.a.a'. Check your module definition

To Reproduce
Steps to reproduce the behavior:

  1. Create a app with androidx ViewModel dependency
  2. Declare a viewmodel dependency
  3. Request the viewmodel dependency using by viewmodel
  4. Set minifyEnable to true
  5. Build a release
  6. See error

Expected behavior
Find the dependency and don't crash

Koin project used and used version (please complete the following information):
[e.g]: koin-core version 1.0.0-beta3

Additional context
When activating logs, it shows:
declare Factory [class='com.app.b.a.a', binds~(androidx.lifecycle.u)]

Solution
After declare proguard rule:
-keepnames class androidx.lifecycle.ViewModel
logs show:
declare Factory [class='com.app.b.a.a', binds~(androidx.lifecycle.ViewModel)]
and dependency resolution go fine

@edipo2s edipo2s changed the title Proguard when using androidx ViewModel Need proguard rule when using androidx ViewModel Jul 26, 2018
@arnaudgiuliani arnaudgiuliani added android status:checking currently in analysis - discussion or need more detailed specs type:issue labels Aug 8, 2018
@arnaudgiuliani arnaudgiuliani self-assigned this Aug 8, 2018
@arnaudgiuliani arnaudgiuliani added this to the 1.0.0 milestone Aug 8, 2018
@arnaudgiuliani
Copy link
Member

Thanks, I'll check that!

@arnaudgiuliani
Copy link
Member

this is a regression. Koin viewmodel features do not have to break pro guard.
It's fixed in 1.0.0-beta-5, you won't required any proguard rule for Koin.

@Pantkowsky
Copy link

Pantkowsky commented Jun 29, 2019

Seems like the same issue came back in 2.0.0-GA3

Getting a crash when injecting a ViewModel -> can't replicate as it happens only in edge cases, but I do get reports back with that stacktrace from my users.

Caused by org.koin.core.error.NoBeanDefFoundException No definition found for 'c.a.a.a.e.f' has been found. Check your module definitions.

My proguard setup:

-keepnames class androidx.lifecycle.ViewModel
-keepclassmembers class * extends androidx.lifecycle.ViewModel { <init>(...); }
-keepclassmembers class * implements androidx.lifecycle.LifecycleObserver { <init>(...); }
-keepclassmembers class * implements androidx.lifecycle.LifecycleOwner { <init>(...); }
-keepclassmembers class androidx.lifecycle.Lifecycle$State { *; }
-keepclassmembers class androidx.lifecycle.Lifecycle$Event { *; }
-keep class * implements androidx.lifecycle.LifecycleOwner { public <init>(...); }
-keep class * implements androidx.lifecycle.LifecycleObserver { public <init>(...); }

even adding -keep class androidx.lifecycle.** { *; } does not help -> still getting this issue.

Just updated to 2.0.1 with hopes that it will help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android status:checking currently in analysis - discussion or need more detailed specs type:issue
Projects
None yet
Development

No branches or pull requests

3 participants