Obfuscation Parcelable and Serializable for Navigation Component

Last couple of years, as Android Developers we use Navigation Component for navigation structure of our applications or change existing navigation structure to it. Navigation Component provides us the speed to connect screen with each other and setup deep link structure easily.

I don’t tell you everything from the beginning. What is deep link?, What is nav-graph? bla bla . But I just want to pay attention to argType for navigations.

Sometimes we need to use string, integers, long primitive types to pass arguments between screen (Fragments, Activities etc). In some other cases, we need entities to pass into another screen. Before navigation component, we could make this with Bundle and Intents. Actually Navigation Component uses this structure in the background. Here is important, if you want to move entities as arguments to another screen you must inherit your entity classes from Parcelable or Serializable. At this point everything is OK. 👌

You complete your application and want to send to Google Play Store. You should shrink and obfuscate your codes with Proguard or Dexguard. When you use parcelable class as argType for navigation argument, just add below codes into your proguard files, otherwise your application will get a crash 😔.

-keepnames class * extends android.os.Parcelable
-keepnames class * extends java.io.Serializable

Happy coding my friends, I hope this info will help you all.




Oktein Company, Software Engineer, Python Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Android: No view found for id error

Android Example : Offline Database App with WorkManager (Part I)

DroidVPN — Easy Android VPN

DroidVPN - Easy Android VPN

💉Inject LiveData into JobIntentService and How to🔫 Test It

Test DPC

Sample VoIP Calling App in Android

How to take your beginner Android skills to the next level by studying open-source Android Apps

Make COVID — 19 App with Kotlin

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Oguzhan Alpayli

Oguzhan Alpayli

Oktein Company, Software Engineer, Python Enthusiast

More from Medium

Way ahead for OTAs

Radical Acceptance by Tara Brach: Summary and Notes

How Philip Belamant Empowers Consumers by Encouraging Change in the BNPL Industry — London Post

Creative Idea for Feature in an Application through PRD