Pro Yearly is on sale from $80 to $50! »

Prepare for Android 8.0/GDG-Kobe 2017-09-18

Cf72ecd4105b5818fcabcc0c0aaeee22?s=47 jsugai
October 04, 2017

Prepare for Android 8.0/GDG-Kobe 2017-09-18

Cf72ecd4105b5818fcabcc0c0aaeee22?s=128

jsugai

October 04, 2017
Tweet

Transcript

  1. Prepare for Android 8.0 Mercari, Inc

  2. About me Jun Sugai @calciolife Mercari, Inc


  3. Agenda ɾػೳରԠ ɾ։ൃ؀ڥ΁ͷରԠ ɾϥΠϒϥϦͷΞοϓσʔτ

  4. What is Android Oreo?

  5. "Coming hand-in-hand with the Android Oreo release is a female

    superhero (think: green Android mascot with a belly made from an Oreo), which the brands say is meant to mix the "playfulness" of Oreo and the "intelligence" of Android."
  6. Migrating to Android 8.0 ΍ͬͯ·͔͢?

  7. ࢀߟαΠτ w.JHSBUJOHUP"OESPJE
 IUUQTEFWFMPQFSBOESPJEDPNBCPVUWFSTJPOTPSFPBOESPJENJHSBUJPOIUNM w"OESPJE#FIBWJPS$IBOHFT
 IUUQTEFWFMPQFSBOESPJEDPNBCPVUWFSTJPOTPSFPBOESPJEDIBOHFTIUNM

  8. ରԠͷఆٛ App ͕Android8.0Ͱ ΞϓϦ͕ैདྷ௨Γͷػೳ͕ఏڙͰ͖Δ͜ͱ  8.0͔Βఏڙ͞ΕΔ৽ػೳʹରԠ͢Δ͜ͱ

  9. None
  10. 1΍ͬͯ 2 Λ΍Δ

  11. None
  12. ϙΠϯτ 1.API ΍ OS ͷ࢓༷͕มߋ or ௥Ճ͞Εͯڍಈ͕มΘΔ 2. ར༻͍ͯ͠Δ OSS

    ʹΑͬͯؒ઀తʹ 1 ͷӨڹΛड͚Δ 3. ৽͍͠όʔδϣϯͷ Support Lib ͳͲͰͷόά 4. Gradleͷઃఆ Λ API Level26 ʹͯ͠ݕূ͢Δ
  13. ಈ࡞ݕূ 1. Android 8.0 ୺຤Ͱ app ͷಈ࡞ݕূ͢Δ 2. Gradleͷ֤छઃఆ ΛAPI

    Level26 ʹ֤ͯ͠OSͰݕূ͢Δ ɾ compileSdkVersion 26 ɾ buildToolsVersion '26.0.x' ɾ targetSdkVersion 26
  14. ࠓ·Ͱʹ௚໘ͨ͠ΞϓϦͷෆ۩߹΍ɺΞϓϦͰར༻͍ͯ͠Δ 3rd Party Library ͳͲͰग़͘Θͨ͠ෆ۩߹΍ ιϨʹର͢ΔରԠ๏ͳͲΛҰ෦঺հ͍ͨ͠ͱࢥ͍·͢

  15. Ϧιʔεࢀর android.view.WindowManager$BadTokenException: 
 Unable to add window android.view.ViewRootImpl$xxxxx
 -- permission

    denied for window type 2002
  16. "ଞͷΞϓϦʹॏͶͯදࣔ" Android 4.0~5.x / API Level 14~22 ɾ<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

    ɾWindowManager ʹ addView Android 6.0~7.x / API Level 23~25 ɾࠓ·Ͱͷʹ + RuntimePermission ʹରԠ Android 8.0~ / API Level 26 ɾࠓ·Ͱͷʹ + WindowManager ʹ addView ͢Δͱ͖ͷ LayerType Λ WindowManager.LayoutParams.TYPE_SYSTEM_ALERT ͔Β
 WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY ʹมߋ͢Δඞཁ͕͋Δ
  17. VectorDrawable VectorDrawableCompat Resources$NotFoundException ※8.0 ͔ΒͷػೳͰ͸ͳ͍Ͱ͕͢ Android Studio ͷ update ʹΑΓ

    Vector Asset ͷ࢖͍΍͔͢͞ΒؕΓ΍͍͢έʔε
  18. VectorDrawable Gradle - vectorDrawables.useSupportLibrary = true XML - app:srcCompat="@drawable/xxxx" Ͱࢦఆ͢Δ

    - TextView ͷ CompoundDrawable ͸ StateListDrawable ͷதͰఆٛ ※ίʔυͰࢦఆ͢Δͱ͖΋ಉ͡Ͱ ImageView ͳͲͱ͸ڍಈ͕ҟͳΔ Code - ͲΕΛ࢖͏? - VectorDrawableCompat#create() - ContextCompat#getDrawable() - ResrouceCompat#getDrwable() ContextCompat#getDrawable() Λ࢖͏
  19. VectorDrawableิ଍ ࢲతͳࡶײ ࠓ·Ͱ΋ SupportLibrary ͷ version ΍ Android Studio ͷ

    version Ͱ૊ΘͤͰ
 ڍಈ͕มΘ͓ͬͯΓɺະͩʹʮίϨͰେৎ෉ʯͱࢥ͑Δύλʔϯ͸ͳ͘ ʮࠓ͸ίϨ͕໰୊͕ͳ͍ॻ͖ํͩͱࢥ͍·͢ʯͱ͍͏ײ৮͔͋͠Γ·ͤΜɻ
  20. Background Execution Limit java.lang.IllegalStateException: Not allowed to start service Intent

    { act=xxxx cmp=xxxx.xxxx.xxxx }: app is in background
  21. Android 8.0 (API level 26) also includes the following changes

    to specific methods: https://developer.android.com/about/versions/oreo/android-8.0-changes.html The startService() method now throws an IllegalStateException if an app targeting Android 8.0 tries to use that method in a situation when it isn't permitted to create background services. The new Context.startForegroundService() method starts a foreground service. The system allows apps to call Context.startForegroundService() even while the app is in the background. However, the app must call that service's startForeground() method within five seconds after the service is created.
  22. Service#startForeground https://developer.android.com/reference/android/app/Service.html#startForeground(int, android.app.Notification) Android 7.1 ͔Β startForeground() ͸ Notification Λදࣔͤͣʹར༻͢Δ

    ͜ͱ͕Ͱ͖ͳ͘ͳΓ·ͨ͠ɻ ͦͷͨΊैདྷɺόοΫάϥ΢ϯυͰαʔϏεΛར༻ͯ͠ߦ͍ͬͯͨॲཧ͸Ϣʔ βʔʹରͯ͠ॲཧঢ়ଶΛ໌ࣔతʹߦΘΕΔΑ͏ʹͳΓ·͢ɻ [developer preview] Foreground Service Can Avoid Notification Requirement https://issuetracker.google.com/issues/37105213
  23. ͦͷଞ • େ൒ͷ҉໧తͳϒϩʔυΩϟετ͸ΞϓϦͰϚχϑΣετΛ࢖༻ͯ͠ొ࿥͢Δ͜ͱ͕ Ͱ͖·ͤΜɻҠߦϚχϡΞϧʹ΋ manifest ͷͱ͜ΖͰࢦఠ͞Ε͍ͯ·͢ɻ
 com.android.launcher.action.INSTALL_SHORTCUT ͸୺຤ʹಋೖ͞Ε͍ͯΔϗʔϜΞϓ ϦશͯʹΞϓϦͷγϣʔτΧοτΛ࡞੒͢Δ҉໧తͳ intent

    Λ௨஌͢Δ΋ͷͰ͕ͨ͠ ར༻Ͱ͖ͳ͍ͷͰ ShortcutManager#requestPinShortcut() Λ࢖͏͜ͱʹͳΓ·͢ • ANDROID_ID ͕ΞϓϦຖʹҟͳΓ·͢ɺಉ͡ΞϓϦͰ΋ॺ໊͕ҟͳΕ͹ҟͳΔ ANDROID_ID ׂ͕ΓৼΒΕ·͢ɻ
  24. ·ͱΊ "OESPJE8.0Ͱಋೖ͞Εͨ৽ػೳ΋/PUJpDBUJPO%PUT΍ "VUPpMMͷΑ͏ʹσϑΥϧτͷಈ࡞Ͱద༻͞ΕΔ৔߹΋͋ Γ·͢ɻ ͨͩݕূͰ͸ैདྷͷػೳ͚ͩͰ͸ͳ͘"1*-FWFMΛద੾ͳ όʔδϣϯʹ্͛Δ͜ͱͰΞϓϦʹ಺ࡏ͢Δ໰୊ʢޓ׵ੑ ʹ໰୊ͷ͋Δ࣮૷Λ͍ͯ͠ΔՕॴͳͲʣΛݦࡏԽ͢Δ͜ͱ ͕Ͱ͖ΔͷͰ"1*-FWFM26 "OESPJE8.0ͷ૊Έ߹Θͤ Ͱͷݕূ͸ඞͣ΍͓ͬͯ͘ͱྑ͍ͱࢥ͍·͢ɻ