LoginSignup
64
47

More than 5 years have passed since last update.

あなたのAndroidアプリをInstant Appsに対応させる6つの手順

Posted at

Google I/O 2016で話題になったInstant Appsについて、興味を持っているデベロッパー向けの事前情報が公開されました。じっくり読みがてら翻訳しましたので公開させてもらおうと思います。

読みながら気になったのですが、フレームワーク名としての「Instant Apps」という言葉とは別に、従来のインストールして使うアプリと対比するようなニュアンスで「instant app」という言葉が使われていました。これについては、本文中で区別し、「インスタントアプリ」と訳しています。ご了承ください。

Preparing Your App(皆さんのアプリを準備する)

Instant Apps is in an Early Access Program with a limited set of developers.

Instant Appsは限られた開発者に向けたアーリーアクセスプログラム中であり、試せる開発者は限られています。

We would encourage interested developers to begin brainstorming the optimal user experience to build your instant app experience around. The best instant app experiences are focused on helping the user accomplish a task quickly (e.g. watching a video or making a purchase).

興味を持ってくれた開発者の皆さんには、インスタントアプリを活かした最高のユーザー体験について、ブレインストーミングを始めておくことをオススメします。インスタントアプリの使いみちとして効果が出やすいのは、ユーザーが何らかのタスク(ビデオを見る、何かを買う、など)を素早く達成できるように注力したときです。

You can also start getting your app ready for Instant Apps by working through this list of steps. Many of these are considered best practices for Android apps generally.

また、皆さんはこの後に紹介する各ステップに取り組むことで、あなたのアプリをInstant Appsへの準備を始めておくこともできます。どれもAndroidアプリを汎用的にするための、よく考えられたベストプラクティスです。

1. アプリから不要な大荷物を削ろう(Remove any unneeded bulk from your app)

Get rid of any unknown/unused permissions, unused components, unneeded third-party dependencies, and libraries. Removing these items can dramatically reduce the size of your app and improve performance significantly. See information on Reducing APK size.

知らない/使ってないパーミッションはすべて消しましょう。使ってないコンポーネントや必要のないサードパーティの依存性やライブラリも消しましょう。こういったものを消すと、劇的にアプリのサイズが小さくなったり、有意にパフォーマンスが向上したりします。詳しくはReducing APK sizeを御覧ください。

2. URLベースのナビゲーションをサポートする(Support URL-based navigation)

Android Instant Apps automatically handles web links using the App Links feature introduced in Android 6.0. As such, App Links are required in order to support URL-based navigation of Android Instant Apps. To get started with App Links, see the information on Handling App Links and the guide to implementing Digital Asset Links.

Android Instant Appsは、Android 6.0で導入されたApp Linksの機能を使って、ウェブのリンクを自動でハンドリングします。言い換えると、Android Instant AppsでURLベースのナビゲーションを行うためには、App Linksが必要になるということでもあります。App Linksを導入するにあたっては、Handling App Linksguide to implementing Digital Asset Linksを参照してください。

Android Instant Apps uses URLs for all navigation. When a user taps a link to your instant app, they go to a specific activity within your app. If the link fails or the user taps the link on an unsupported device, the browser opens and shows your website. Also, an activity cannot launch another activity directly within an instant app; rather, it must request the URL address that corresponds to that activity.

Android Instant AppsはすべてのナビゲーションにURLを使います。ユーザーがあなたのインスタントアプリへのリンクをタップすると、あなたのアプリ内の特定のアクティビティへ移動します。もしアプリへのリンクに失敗したり、App Linksがサポートされていないデバイスだった場合には、ブラウザが開いてあなたのWebサイトが開くことになるでしょう。それと、インスタントアプリとして動いているひとつのアクティビティは、別のアクティビティを直接起動することができません。どうしてもInstant Appsの範疇でそういうことがしたいのであれば、その別のアクティビティにもURLアドレスを割り当ててリクエストしたほうがよいでしょう。

3. 必要に応じてアプリをリファクタリングする(Refactor your app, if necessary)

Android instant apps need to be structured into URL-addressable modules that are under 4MB in size. For apps that are larger than 4MB, developers would need to refactor the app into smaller modules that can be downloaded and run independently in response to URL navigation.

インスタントアプリはURLに割り当て可能な単位でモジュールを構築していく必要があるわけですが、各モジュールのサイズは4MB以下にしてください。4MBを超えてしまっているアプリについては、もっと小さいモジュールになるようにリファクタリングを行い、ダウンロードしやすくしたり、URL単位での起動をしやすくしましょう。

Developers are free to choose what to include in each module, but our recommendation is to isolate distinct user flows into different modules. This gives a fast and responsive experience within a flow and additional modules are downloaded only when the user switches flows.

各モジュールに何の機能を入れるかは開発者の自由ですが、ユーザーの操作するフローが独立している機能を異なるモジュールにまとめていくのがオススメです。これによって、ユーザーがやりたいことに対して素早く最適な体験を提供できますし、追加でモジュールをダウンロードするのはユーザーのやりたいこと自体が変わったときだけになります。

For example, when building a retail experience, you might separate your app into four modules: browse, search, item detail, and checkout to allow the user to download modules as needed throughout the purchase flow.

たとえば、あなたがネットショッピングのアプリを作ろうとしたとき、4つのモジュールに分割できます。それは、閲覧、検索、商品詳細、注文です。購入の流れの中で、ユーザーは必要に応じてモジュールをダウンロードしていくことになります。

4. ランタイムパーミッションを実装する(Implement runtime permissions from Android 6.0)

Android Instant Apps use runtime permissions, introduced in Android 6.0. The Android Instant Apps framework ensures that these features work correctly on earlier versions of Android as well. As such, please make sure your app is targeting Android 6.0+ and implement runtime permissions. To learn how to update your app to use Android 6.0 permissions, see the information on Requesting Permissions at Runtime.

Android Instant Appsでは、Android 6.0で登場したランタイムパーミッションを使います。Android Instant Appsのフレームワークは古いバージョンのAndroidでも前項でモジュール化した各種機能が従来通りのアプリの形で問題なく動くことを保証しています。一方で、インスタントアプリとして動かすには、Android 6.0以上をターゲットにしていることと、ランタイムパーミッションを実装してあることを、開発者側で保証しておいてください。Android 6.0におけるパーミッションについて学ぶには、Requesting Permissions at Runtimeを参照してください。

5. ユーザー認証を行いたい場合はSmart Lock for Passwordsを実装する(Implement Smart Lock for Passwords if your app authenticates users)

For instant apps that include login, developers must integrate Smart Lock for Passwords. This allows users to quickly and securely sign in by using the credentials they have saved, as well as for users to remain signed in across app visits. To learn more about Smart Lock, please see information here.

インスタントアプリがログインを必要とする場合、開発者はSmart Lock for Passwordsを利用する必要があります。この機能は、以前に保存してあった認証情報を使って、ユーザーに素早くセキュアなサインインを提供し、何度かアプリを開いた場合にもログイン状態が継続されます。Smart Lockについて学びたい場合は、こちらを参照してください。

6. 何ができないのかを確認する(Identify unsupported features)

User expectations may vary for apps that are installed vs. apps accessed via URL, so certain functionality available to installed apps is not available to instant apps. Developers using any of the below functionality would need to refactor their app to move unsupported features to a separate library module that can be included only in their installed app.

インストールされているアプリと、URLから開いたアプリでは、おそらくユーザーもアプリに対して持つ期待に違いがあります。つまりは、インストールされたアプリで使える"ある機能"は、きっとインスタントアプリでは使えないのだろうな、ということです。開発者が後述する機能を使うには、サポートされていない機能をライブラリモジュールに切り分けて、インストールされたときにしか使えないようにする必要があります。

Instant apps cannot:

Run on the device without users being aware. Foreground services are available. Instant apps can only be started through activities that support App Links, so services, content providers or broadcast receivers won't be able to start your app. Push notifications are currently not supported in instant apps.

ユーザーが気づかない場所では動作できません。フォアグラウンドサービスは使えます。インスタントアプリはApp Linksの管理下にあるアクティビティのみを起動できます。そのため、サービス、コンテントプロバイダ、ブロードキャストレシーバを起動することはできません。プッシュ通知も現状ではインスタントアプリ内では使用できません。

Access external storage on the device. However, instant apps can temporarily use internal storage private to the app.

デバイスの外部ストレージにはアクセスできません。しかし、インスタントアプリはアプリのプライベートな内部ストレージを一時的に利用することができます。

Discover or interact directly with the list of installed apps on the device (e.g. via explicit intents).

デバイスにインストールされたアプリを探したり連携したりすることができません。明示的インテントなどがこれにあたります。

Receive broadcasts from the system or other installed apps, or use GCM. In the future, instant apps may support a limited set of broadcasts while the app is running.

システムやインストールされたアプリが発行したブロードキャストを受け取ることはできませんし、GCMも使えません。将来的には、インスタントアプリも起動中に限っては一部のブロードキャストを受け取れるようにしたいです。

Access device identifiers that (1) persist longer than the instant app and (2) are not resettable by the user (e.g. Settings Secure Android ID (SSAID), Build Serial, Mac Addresses, IMEI, IMSI). NOTE: developers will have access to the Advertising ID.

次の識別情報にアクセスすることはできません。(1) インスタントアプリよりも長い時間保存されるもの、(2) ユーザーがリセットできないもの(例:Settings Secure Android ID (SSAID), Build Serial, Mac Addresses, IMEI, IMSI)

NOTE: 広告IDにはアクセスできます。

Change device settings (e.g. change the user's wallpaper).

デバイスの設定を変えることはできません。

64
47
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
64
47