Upgrade to Pro — share decks privately, control downloads, hide ads and more …

既存のAndroidプロジェクトを Jetpack Composeに移行してみる / Migrate existing Android project to Jetpack Compose

Nabe
February 19, 2021

既存のAndroidプロジェクトを Jetpack Composeに移行してみる / Migrate existing Android project to Jetpack Compose

2021/02/19
Mobile Act ONLINE #3
https://mobileact.connpass.com/event/200515/

Nabe

February 19, 2021
Tweet

More Decks by Nabe

Other Decks in Programming

Transcript


  1. .PCJMF"DU0/-*/&
    طଘͷ"OESPJEϓϩδΣΫτΛ
    +FUQBDL$PNQPTFʹҠߦͯ͠ΈΔ

    View full-size slide

  2. 1SPGJMF
    w ͳ΂
    w 5XJUUFS!/BCF$PUU
    w (JU)VC/6NFSP"OE%FW
    w גࣜձࣾ͸ͯͳ
    w "OESPJEJ04BQQMJDBUJPOFOHJOFFS

    View full-size slide

  3. +FUQBDL$PNQPTFͱ͸
    w "OESPJEʹ͓͚Δએݴత6*ͷϑϨʔϜϫʔΫ
    w "OESPJEҎ߱Ͱ࢖͑Δ
    w ݱࡏͰBMQIB͕࠷৽
    w ೥ʹ4UBCMFʹͳΔ༧ఆ
    w IUUQTXXXZPVUVCFDPNXBUDI
    W6#XGR#QJ86GFBUVSFZPVUVCFU
    ͜ͷઌɺ+FUQBDL$PNQPTFΛ$PNQPTFͱলུͯ͠දه͠·͢

    View full-size slide

  4. ࠓ೔࿩͢͜ͱ
    w ࣮ࡍʹ͋ΔϓϩδΣΫτΛ+FUQBDL$PNQPTFʹ׬શҠߦͯ͠Έ·͢
    w ͲͷΑ͏ͳखॱͰҠߦ͢Δ͜ͱʹͳΔͷ͔
    w ҠߦͰେมͩͬͨՕॴ
    w +FUQBDL$PNQPTFʹඋ͑ͯࠓ͔ΒͰ͖Δ͜ͱ

    View full-size slide

  5. +FUQBDL$PNQPTFʹҠߦ͢Δखॱ
    طଘͷ7JFXͱಉ͡σβΠϯͷ$PNQPTBCMFGVOΛ࣮૷͢Δ
    w "OESPJE4UVEJPͰ1SFWJFXΛ֬ೝͰ͖Δ
    "DUJWJUZPS'SBHNFOUͷը໘୯ҐͰ$PNQPTF΁ஔ͖׵͑Δ
    w $PNQPTF͸"DUJWJUZ'SBHNFOU7JFX୯ҐͰͷಋೖ͕Մೳ
    ը໘ભҠΛ$PNQPTFͰભҠͤ͞ΔΑ͏ʹ͢Δ

    View full-size slide

  6. ࠓճҠߦ͢ΔϓϩδΣΫτ
    w 6IPPJ1JD#PPL"OESPJEͱ͍͏ɹ
    ΢ϗʔΠ͞Μ !UIF@VIPPJ
    ͕
    (JU)VCʹ044ͱͯ͠ެ։͍ͯ͠
    ΔϓϩδΣΫτΛ$PNQPTFʹҠ
    ߦͯ͠Έ·͢
    w IUUQTHJUIVCDPNVIPPJ
    6IPPJ1JD#PPL"OESPJE
    w ͜ͷΞϓϦ͸Ұཡɺৄࡉͱγϯϓ
    ϧͳߏ੒ͷΞϓϦͰ͢

    View full-size slide

  7. ΞΠςϜΛ࣮૷

    View full-size slide

  8. ΞΠςϜΛ࣮૷

    View full-size slide

  9. ϦετΛ࣮૷

    View full-size slide

  10. ϦετΛ࣮૷

    View full-size slide

  11. Ұཡͷը໘Λ࣮૷

    View full-size slide

  12. Ұཡͷը໘Λ࣮૷

    View full-size slide

  13. σʔλΛҰཡʹ൓ө
    w $PNQPTF͕௚઀ѻ͑Δ
    0CTFSWBCMFͳܕͱͯ͠4UBUF
    ͕༻ҙ͞Ε͓ͯΓɺ-JWF%BUBΛ
    PCTFSWF"T4UBUFͰ$PNQPTF
    Ͱ؍ଌͰ͖ΔΑ͏ʹ
    w -JWF%BUBɺ4UBUF'MPXɺ
    3Y+BWB͸4UBUFʹม׵͢Δ
    ࢓૊Έ͕༻ҙ͞Ε͍ͯΔ

    View full-size slide

  14. 'SBHNFOUʹ$PNQPTFΛදࣔ
    w $PNQPTF7JFXΛ'SBHNFOUͷ7JFX
    ʹઃఆ͠ɺTFU$POUFOU಺ʹ
    $PNQPTFΛॻ͚ͩ͘
    w .ED5IFNF͸ϓϩδΣΫτͰઃఆ͞
    Ε͍ͯΔ5IFNFΛ$PNQPTFͷ
    5IFNFʹஔ͖׵͑ͯ͘ΕΔ΋ͷ
    w IUUQTHJUIVCDPNNBUFSJBM
    DPNQPOFOUTNBUFSJBM
    DPNQPOFOUTBOESPJEDPNQPTF
    UIFNFBEBQUFS

    View full-size slide

  15. ଞͷը໘΋Ҡߦ͢Δ
    w جຊతʹͲͷը໘Ͱ΋खॱ͸ಉ͡Ͱ
    طଘͷ7JFXͱಉ͡σβΠϯͷ$PNQPTBCMFGVOΛ࣮૷͢Δ
    "DUJWJUZPS'SBHNFOUͷը໘୯ҐͰ$PNQPTF΁ஔ͖׵͑Δ
    Ͱஔ͖׵͍͖͑ͯ·͢
    w ଞͷը໘ͷஔ͖׵͑͸লུ͠·͢

    View full-size slide

  16. ը໘ભҠΛҠߦ͢Δ
    w ࠓճ͸+FUQBDLʹ͋Δ/BWJHBUJPO$PNQPTFΛ࢖ͬͯભҠॲཧΛ࣮૷
    w IUUQTEFWFMPQFSBOESPJEDPNKFUQBDLDPNQPTFOBWJHBUJPO
    w /BWJHBUJPO$PNQPTFΛ࢖ΘͣʹભҠॲཧΛؤு࣮ͬͯ૷͢Δ͜ͱ΋Ͱ͖Δ

    View full-size slide

  17. ը໘ͷάϥϑΛ࣮૷͢Δ
    w /BW)PTUͷதͰDPNQPTBCMFΛ࢖༻͠
    ͯભҠʹ࢖͏SPVUFͱ$PNQPTBCMFͷ
    ఆٛΛ࣮૷͢Δ
    w /BWJHBUJPOͷ,PUMJO%4-ͷ࣮૷ͱಉ
    ͡
    w ͜ͷDPNQPTBCMFͰ͸SPVUFʹઃఆ͠
    ͨύεͰ%FFQMJOLΛੜ੒ͯ͠ભҠΛ࣮
    ݱ͍ͯ͠Δ
    w /BW$POUSPMMFSʹఆٛͯ͋͠ΔSPVUFΛ
    ౉ͤ͹ભҠͰ͖Δ

    View full-size slide

  18. ભҠઌͷը໘ʹ஋Λ౉͢
    w SPVUFʹ౉͍ͨ͠஋Λఆٛ͠ɺ
    BSHVNFOUTʹܕ৘ใΛఆٛ͠·͢
    w ड͚औΔ࣌͸DPNQPTBCMFʹฦͬ
    ͯ͘Δ/BWCBDL4UBDL&OUSZ͔Β
    ड͚औΓ·͢
    w ભҠ࣌ʹ4FSJBMJ[BCMF΍
    1BSDFMBCMFΛ౉͢खஈ͸
    BMQIB࣌఺Ͱ͸ͳ͍

    View full-size slide

  19. ը໘ભҠΛҠߦ͢Δ
    w ϧʔτͷ"DUJWJUZʹ
    TFU$POUFOUͰ$PNQPTFΛද
    ࣔ͢ΔΑ͏ʹ͢Ε͹Ҡߦ׬ྃ

    View full-size slide

  20. $PNQPTFʹҠߦͯ͠Έͯ
    w طଘͷ7JFXͱ$PNQPTFʹޓ׵͕͋Δ͔Βಋೖ͠΍͍͢
    w ࠓճ͸͍ͯ͠ͳ͍͕$PNQPTFʹ͜Ε·Ͱͷ7JFXΛදࣔͤ͞Δ͜ͱ΋Մೳ
    w ը໘ભҠͷҠߦ͕೉ॴͰɺ'SBHNFOU/BWJHBUJPOͱ/BWJHBUJPO$PNQPTF
    ͷซ༻͕೉͘͠ɺશͯͷը໘ભҠΛҰ౓ʹஔ͖׵͑ΔͱͳΔͱίετ͕ߴ͍
    w 'SBHNFOU/BWJHBUJPO͸ͦͷ··ʹத͚ͩ$PNQPTFΛ࢖͏ͷ͕ࠓͷͱ
    ͜Ζແ೉ͦ͏
    w $PNQPTFࣗମ͸׳ΕΔͱշదʹϨΠΞ΢τͰ͖Δ

    View full-size slide

  21. $PNQPTFΛݟӽͯ͠ࠓͰ͖Δ͜ͱ
    w "OESPJE"SDIJUFDUVSF$PNQPOFOUʹଇ࣮ͬͨ૷ɾઃܭΛ͍ͯ͠Δ͜ͱ
    w ެ͔ࣜΒ΋(VJEFUPBQQBSDIJUFDUVSFͱ͍͏υΩϡϝϯτ͕༻ҙ͞Ε͍ͯΔ
    w IUUQTEFWFMPQFSBOESPJEDPNKFUQBDLHVJEF
    w ݫີʹ͸7JFX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