Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
nacatl_slide_03_AAC_Navigation_SafeArfgs.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
nacatl
November 27, 2019
95
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
nacatl_slide_03_AAC_Navigation_SafeArfgs.pdf
nacatl
November 27, 2019
More Decks by nacatl
See All by nacatl
Flutterにおけるアプリ内課金実装 -Android/iOS完全なる統一 -
nacatl
2
8.3k
Navigation Componentを実戦投入した際の感動、便利さ、そしてつまづき
nacatl
0
3.2k
nacatl_slide_04_AAC_Navigation_Toolbar
nacatl
0
840
nacatl_slide_02_MapView_in_Recycler_view.pdf
nacatl
1
360
DynamicLinks 知られざる?Firebaseの秘技
nacatl
2
1.4k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
640
How to make the Groovebox
asonas
2
2.4k
Navigating Weather and Climate Data
rabernat
0
520
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
Test your architecture with Archunit
thirion
2
2.4k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
450
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Transcript
Copyright 2018 Studyplus, Inc. All Rights Reserved. Jetpack Navigation の
SafeArgsでつまずいた話 Yuzuru Nakashima / Studyplus Inc. 2019.11.27 @ あるあるLT Vol.08
自己紹介 ✎ なかてぃる affinity_robots nacatl ✎ スタディプラスのAndroidエンジニア ✎ 趣味: Magic
the Gathering
アジェンダ ✎ Jetpack Navigation ライブラリ ✎ SafeArgsとは ✎ つまづいたこと ✎
解決方法
Jetpack Navigation ライブラリ Fragment画面遷移の改革
Jetpack Navigation ライブラリ - Fragmentによる画面遷移を視覚的に デザインできるライブラリ - Fragment遷移のバックスタックとかも 管理してくれる
Jetpack Navigation ライブラリ
SafeArgsとは What is the SafeArgs?
SafeArgsとは? - Fragment間のBundleによるデータのput/getを 型安全な形でラップしてくれる機能 - getSerializable as? Hoge とか書かずに済む -
~~FragmentArgs という名前の ラッパークラスが自動生成される
SafeArgsとは? <fragment android:id="@+id/YyyFragment" > <argument android:name="myArg" app:argType="~~.~~.~~.Hoge" /> </fragment> <!--
Hoge は Serializable or Parcelable -->
SafeArgsとは? // 遷移元Fragmentの遷移処理箇所 findNavController().navigate( XxxFragmentDirections.actionToYyy( myArg = Hoge() ) )
SafeArgsとは? // 遷移先Fragment // フィールドとしてby navArgs()で取得 private val args: YyyFragmentArgs
by navArgs() // Hoge型として型安全で中身を受け取れる val myArg: Hoge = args.myArg
つまずいたこと Missteps
難読化したらInflateException出た つまずいたこと
難読化したらInflateException出た Didn’t find class ~.~.~.Hoge つまずいたこと
つまずいたこと ピリオドで始めれば相対パスでも書けるらしい… <fragment android:id="@+id/YyyFragment" > <argument android:name="myArg" app:argType=".Hoge" /> </fragment>
難読化しなくてもInflateException出た つまずいたこと
難読化しなくてもInflateException出た Didn’t find class {パッケージ名}.debug.Hoge つまずいたこと
“debug”!? つまずいたこと
つまずいたこと 相対パスで書くと実際に動いてるアプリの パッケージ名の後に書いたパスが付く - Build Variants でSuffixとか付けてると無理 - マルチモジュールで実際のクラスのディレクトリが ~~.app.{モジュール名}.Hoge
とかになってても無理
解決方法 Solutions
解決方法 フルパスで書いて難読化対象から外そう - クラスに @Keep アノテーションつける - proguard-rules.proで -keepnames に定義する
公式ドキュメントにもそう書かれている https://developer.android.com/guide/navigatio n/navigation-pass-data?hl=JA#proguard_conside rations
- SafeArgsは便利だけど現状一工夫必要 - 公式ドキュメントを逐一確認しよう
ご静聴ありがとうございました