Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hand-made Crash Report of Android Library
Search
petitviolet
October 13, 2015
Technology
1
2.1k
Hand-made Crash Report of Android Library
http://connpass.com/event/20240/
How to implement crash report of Android-Library
petitviolet
October 13, 2015
Tweet
Share
More Decks by petitviolet
See All by petitviolet
Stripeで請求書払い&銀行振込を実装する
petitviolet
0
1.2k
ピュアなドメインを支える技術/pure domain model and the technology behind it
petitviolet
14
9.8k
小さく始めるクラウドネイティブ/small start CloudNative
petitviolet
0
1.7k
2019年だからこそ12factor app/The Twelve-Factor app in 2019
petitviolet
1
970
実践GraphQL on Scala/Real world GraphQL on Scala
petitviolet
8
2.9k
Kubernetesを知る/Introduction Kubernertes
petitviolet
1
610
GraphQL on Scala
petitviolet
3
2.6k
Microservices Batch on GAE
petitviolet
0
1.9k
Web API Design
petitviolet
18
8.1k
Other Decks in Technology
See All in Technology
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
190
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
160
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
170
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
310
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
複雑なState管理からの脱却
sansantech
PRO
1
150
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
880
AGIについてChatGPTに聞いてみた
blueb
0
130
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
220
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Side Projects
sachag
452
42k
Fireside Chat
paigeccino
34
3k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Teambox: Starting and Learning
jrom
133
8.8k
Automating Front-end Workflow
addyosmani
1366
200k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
How to Ace a Technical Interview
jacobian
276
23k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Transcript
Hand-made CrashReport of Android Library potatotips #22 @petitviolet
About me • @petitviolet • Fringe81 Co., Ltd. • ࠂSDKͷAndroid/iOS։ൃ
• ࠷ۙScalaॻ͍ͯ·͢
ΫϥογϡϨϙʔτ
None
CrashReport • ΞϓϦέʔγϣϯ͕Ϋϥογϡͨ࣌͠ͷঢ়گ ΛϨϙʔτͱͯ͠ૹ৴ • ͷछྨ • OS • ελοΫτϨʔε
• etc.
crashlytics https://try.crashlytics.com/
ACRA https://github.com/ACRA/acra
Desire • ϥΠϒϥϦىҼͷΫϥογϡϩάऩू͍ͨ͠ • ΞϓϦͷΫϥογϡϩάऩू͠ͳ͍ • ͦΕCrashlyticsʹ͓ͤ • ಠࣗͷσʔλ͕ཉ͍͠
UncaughtException • (جຊతʹ)Ϋϥογϡ͢Δͱ͖ʹඈͿྫ֎ • catch͞Εͳ͔ͬͨͷͰuncaught • ErrorͰͳ͘Exception
UncaughtExceptionHandler • UncaughtExceptionΛͲ͏ѻ͏͔ • σϑΥϧτͷಈ࡞ getDefaultUncaughtExceptionHandler • Defaultͷಈ࡞Λյ͞ͳ͍ͨΊʹอଘ
جຊ෦ class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { private static final
String PACKAGE_NAME = BuildConfig.APPLICATION_ID; private final Thread.UncaughtExceptionHandler mDefaultHandler; private WeakReference<Context> mContext; volatile private static boolean sCrashing = false; public MyUncaughtExceptionHandler(Context context) { mContext = new WeakReference<>(context.getApplicationContext()); mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); } }
جຊ෦ class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { private static final
String PACKAGE_NAME = BuildConfig.APPLICATION_ID; private final Thread.UncaughtExceptionHandler mDefaultHandler; private WeakReference<Context> mContext; volatile private static boolean sCrashing = false; public MyUncaughtExceptionHandler(Context context) { mContext = new WeakReference<>(context.getApplicationContext()); mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); } } UncaughtExceptionHandlerΛܧঝ
جຊ෦ class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { private static final
String PACKAGE_NAME = BuildConfig.APPLICATION_ID; private final Thread.UncaughtExceptionHandler mDefaultHandler; private WeakReference<Context> mContext; volatile private static boolean sCrashing = false; public MyUncaughtExceptionHandler(Context context) { mContext = new WeakReference<>(context.getApplicationContext()); mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); } } DefaultͷUncaughtExceptionHandlerΛอଘ UncaughtExceptionHandlerΛܧঝ
جຊ෦ @Override public void uncaughtException(final Thread thread, final Throwable ex)
{ if (sCrashing) { mDefaultHandler.uncaughtException(thread, ex); return; } sCrashing = true; StackTraceElement[] stackTraceElements = ex.getStackTrace(); boolean inLibraryException = false; for (StackTraceElement stackTraceElement : stackTraceElements) { if (stackTraceElement.getClassName().contains(PACKAGE_NAME)) { inLibraryException = true; break; } } // ϥΠϒϥϦͰͷΫϥογϡͩͬͨ߹ϩάΛૹΔ if (inLibraryException) { try { sendCrashReport(ex); } catch (Exception e) { e.printStackTrace(); } } // ϝΠϯεϨουͩͬͨ߹ࢮ͵͔͠ແ͍ if (thread.getId() == Looper.getMainLooper().getThread().getId() || !inLibraryException) { mDefaultHandler.uncaughtException(thread, ex); } }
@Override public void uncaughtException(final Thread thread, final Throwable ex) {
if (sCrashing) { mDefaultHandler.uncaughtException(thread, ex); return; } sCrashing = true; StackTraceElement[] stackTraceElements = ex.getStackTrace(); boolean inLibraryException = false; for (StackTraceElement stackTraceElement : stackTraceElements) { if (stackTraceElement.getClassName().contains(PACKAGE_NAME)) { inLibraryException = true; break; } } ͢ͰʹΫϥογϡͨ͠ޙͳΒࢮ͵
@Override public void uncaughtException(final Thread thread, final Throwable ex) {
if (sCrashing) { mDefaultHandler.uncaughtException(thread, ex); return; } sCrashing = true; StackTraceElement[] stackTraceElements = ex.getStackTrace(); boolean inLibraryException = false; for (StackTraceElement stackTraceElement : stackTraceElements) { if (stackTraceElement.getClassName().contains(PACKAGE_NAME)) { inLibraryException = true; break; } } ͢ͰʹΫϥογϡͨ͠ޙͳΒࢮ͵ LibraryͷΫϥογϡ͔Ͳ͏͔ఆ
// ϥΠϒϥϦͰͷΫϥογϡͩͬͨ߹ϩάΛૹΔ if (inLibraryException) { try { sendCrashReport(ex); } catch
(Exception e) { e.printStackTrace(); } } // ϝΠϯεϨουͩͬͨ߹ࢮ͵͔͠ແ͍ if (thread.getId() == Looper.getMainLooper().getThread().getId() || !inLibraryException) { mDefaultHandler.uncaughtException(thread, ex); } }
// ϥΠϒϥϦͰͷΫϥογϡͩͬͨ߹ϩάΛૹΔ if (inLibraryException) { try { sendCrashReport(ex); } catch
(Exception e) { e.printStackTrace(); } } // ϝΠϯεϨουͩͬͨ߹ࢮ͵͔͠ແ͍ if (thread.getId() == Looper.getMainLooper().getThread().getId() || !inLibraryException) { mDefaultHandler.uncaughtException(thread, ex); } } LibraryͷΫϥογϡͳΒϩάૹ৴
// ϥΠϒϥϦͰͷΫϥογϡͩͬͨ߹ϩάΛૹΔ if (inLibraryException) { try { sendCrashReport(ex); } catch
(Exception e) { e.printStackTrace(); } } // ϝΠϯεϨουͩͬͨ߹ࢮ͵͔͠ແ͍ if (thread.getId() == Looper.getMainLooper().getThread().getId() || !inLibraryException) { mDefaultHandler.uncaughtException(thread, ex); } } Library֎ͷΫϥογϡ͔UIεϨουͳΒࢮ͵ LibraryͷΫϥογϡͳΒϩάૹ৴
جຊ෦ @Override public void uncaughtException(final Thread thread, final Throwable ex)
{ if (sCrashing) { mDefaultHandler.uncaughtException(thread, ex); return; } sCrashing = true; StackTraceElement[] stackTraceElements = ex.getStackTrace(); boolean inLibraryException = false; for (StackTraceElement stackTraceElement : stackTraceElements) { if (stackTraceElement.getClassName().contains(PACKAGE_NAME)) { inLibraryException = true; break; } } // ϥΠϒϥϦͰͷΫϥογϡͩͬͨ߹ϩάΛૹΔ if (inLibraryException) { try { sendCrashReport(ex); } catch (Exception e) { e.printStackTrace(); } } // ϝΠϯεϨουͩͬͨ߹ࢮ͵͔͠ແ͍ if (thread.getId() == Looper.getMainLooper().getThread().getId() || !inLibraryException) { mDefaultHandler.uncaughtException(thread, ex); } } LibraryͷΫϥογϡ͔Ͳ͏͔ఆ LibraryͷΫϥογϡͳΒϩάૹ৴ Library֎ͷΫϥογϡ͔UIεϨουͳΒࢮ͵ ͢ͰʹΫϥογϡͨ͠ޙͳΒࢮ͵
େࣄͳ͜ͱ • ϥΠϒϥϦΫϥογϡϩάΈͯվળ • ΞϓϦͷअຐΛ͠ͳ͍ • σϑΥϧτͷಈ࡞Λࡴ͞ͳ͍ • ϑϦʔζͤ͞ͳ͍Α͏ʹ •
ແݶΫϥογϡ͠ͳ͍Α͏ʹཧ • ໘Ͱϑϥάཧ