致命傷を避けるための例外実例集

 致命傷を避けるための例外実例集

Bbe9718bebdafbdc8dabbe3cadf1bc46?s=128

Keishin Yokomaku

November 09, 2016
Tweet

Transcript

  1. 2.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू About Me ▸ Keishin Yokomaku ▸ Drivemode, Inc. /

    Principal Engineer ▸ KeithYokoma: GitHub / Twitter / Qiita / Tumblr / Stack Overflow ▸ Books: Mobile App Dev Guide / Android Academia / Grimoire of Android ▸ Fun: Gymnastics / Cycling / Photography / Motorsport ▸ Today’s Quote: “࣌୅͸ے೑” 2
  2. 3.
  3. 4.

    4

  4. 6.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू ই͸ઙ͍͏ͪʹ࠹͙ ▸ ϦϦʔεઓུͱΫϥογϡݕ஌ͷ࢓૊Έ͸ඞਢςΫχοΫ ▸ Fabric(Crashlytics) ͰΫϥογϡϩάͷऩू ▸ Google Play

    Developer Console Ͱஈ֊తϦϦʔε ▸ ϢʔβϑΟʔυόοΫͷมԽʹؾ෇͘ ▸ ʮ࠷ۙ͜ΜͳϑΟʔυόοΫ͕Α͘དྷͯΔʯ ▸ ʮ͋ͷϑΟʔυόοΫݮͬͨʯ 6
  5. 8.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू Let’s get started! ▸ ຊ೔ͷྫ֎Ϩγϐ ▸ ༗໊Ͳ͜Ζ͔ΒͲϚΠφʔͳ΋ͷ·ͰϞϦϞϦίʔε 8 NullPointerException

    OutOfMemoryError StackOverflowError Illegal**Exception CursorWindowAllocationException TransactionTooLargeException DeadObjectException
  6. 12.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू NullPointerException ▸ ରࡦͷํ๏ ▸ ઃܭʹΑΔରࡦ ▸ ϝιου͕ null Λڐ༰͢Δ͔Ͳ͏͔ද໌͢Δ͜ͱͰɺ


    ୭͕null νΣοΫͷ੹຿Λෛ͏͔ܾΊΔ ▸ NullObject ύλʔϯΛ࢖ͬͯɺԿ΋ى͖ͳ͍Α͏ʹ޻෉͢Δ 12
  7. 13.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू NullPointerException ▸ ରࡦͷํ๏ ▸ ϑϨʔϜϫʔΫͷίʔυͷ೺Ѳ ▸ Ͳ͏͍͏ঢ়گͰϝιου͕ null Λฦ͔͢஌͓ͬͯ͘

    ▸ Support Library ͷ࣮ଶΛ஌͓ͬͯ͘ ▸ ۭ࣮૷ͷ··ϦϦʔε͞Ε͍ͯΔ͕࣌͋Δ ▸ ϑϨʔϜϫʔΫͷ࡞๏ʹ४ͨ͡࡞ΓํΛ֮͑Δ 13
  8. 17.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू StackOverflowError ▸ ελοΫΛ࢖͍௵ͨ͠ͱ͖ʹى͖Δྫ֎ ▸ e.g. ແݶ࠶ؼݺͼग़͠ ▸ ݟམͱ͕ͪ͠ͳՕॴ ▸

    ਂ͗͢ΔϨΠΞ΢τͷωετ: ϨΠΞ΢τ΋݁ہ͸ Java ͷΦϒδΣΫτʹͳΔ ▸ ਂ͗͢Δґଘؔ܎: ա৒ͳϨΠϠԽͰϝιουͷίʔϧελοΫʹݶք͕͘Δ 17
  9. 18.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू StackOverflowError ▸ ରࡦํ๏ ▸ ϨΠΞ΢τͷ֊૚ߏ଄ΛݮΒ͢ ▸ RelativeLayout ΍ ConstraintLayout

    ͳͲͰϑϥοτͳߏ଄ʹ͢Δ ▸ ద੾ͳཻ౓ͰઃܭΛ͢Δ ▸ Clean Architecture ΍ DDD ͳͲΛࢀߟʹ 18
  10. 20.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू Illegal**Exception ▸ छྨ͸৭ʑ ▸ IllegalStateException, IllegalArgumentException, etc… ▸ ݺͼग़͞ΕΔଆ͕૝ఆ͍ͯ͠ͳ͍ঢ়ଶɾҾ਺ʹ௚໘ͨ͠ͱ͖ʹى͖Δ

    ▸ ݺͼग़͢ଆ͕Ҿ਺νΣοΫ΍ঢ়ଶνΣοΫΛ͢Δ͜ͱΛཁٻ͍ͯ͠Δ ▸ ୺຤ґଘͰެࣜͷ Javadoc ʹॻ͍ͯͳ͍ͱ͖ʹඈΜͰ͘Δ͜ͱ͕͋Δ ▸ ո͍͠ͳʁͱࢥͬͨΒ͙͢ʹঢ়ଶ΍Ҿ਺ΛϩάʹͭΊͯूΊΒΕΔ࢓૊ΈΛ 20
  11. 23.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू CursorWindowAllocationException ▸ σʔλϕʔεΛѻ͏ͱ໨ʹ͢Δྫ֎ ▸ Cursor ͕΋ͭσʔλ͕ڐ༰ൣғΛ௒͑ͨͱ͖ʹى͖Δ ▸ ϦϑΝϨϯεʹ Javadoc

    ͕ແ͍ྫ֎͕ͩɺࡶʹ࡞Δͱ໨ܸ͢Δϋϝʹ ▸ CursorWindow ΫϥεͷதͰϋϯυϦϯά͍ͯ͠Δ ▸ CursorWindow.java: http://bit.ly/2eKlL5y 23
  12. 27.

    க໋ইΛආ͚ΔͨΊͷྫ֎࣮ྫू TransactionTooLargeException ▸ Intent ͷ extra ʹ 1mB Λ௒͑Δ String

    Λ౉͢͜ͱͰ΋ى͖Δఔ౓ʹ͸਎ۙͳͱ ͜ΖʹՄೳੑ͕͋Δ ▸ ରࡦํ๏ ▸ ڊେͳσʔλΛ௚઀ѻΘͳ͍ ▸ ϓϩηεؒ௨৴ͷ࣌ؒΛ୹͘͢Δ ▸ ϓϩηεؒ௨৴ͷճ਺ͦͷ΋ͷΛݮΒ͢ 27
  13. 30.
  14. 31.

    31