To get public and personal content from your app into users’ search results in the Google app, start by setting up your app URLs and adding the Firebase App Indexing library.
Add Firebase and the App Indexing library
Although you don’t strictly need Firebase to get your app's public content indexed by Google, App Indexing can help you get more out of Search.
- If you haven't already, add Firebase to your Android project.
- In your project-level
build.gradlefile, make sure to include Google's Maven repository in both your
- Add the dependency for the Firebase App Indexing Android library to
your module (app-level) Gradle file (usually
Structure links to your app content
Structure your website and app so the URLs that point to pages on your site are the same URLs that point to views in your Android app. Google Search crawls your site for these links, then uses them to send users directly to your app.
For example, consider the simple http://www.recipe-app.com website from the App Indexing codelab. The links in the app are the same HTTP URLs used on the website and follow a clear structure that matches page types to app view types. Follow this type of structure in your app and website.
The recipe-app.com sample has two page types (for recipes and notes), but you could have many more page types on your site, each with a distinct link type. For example, recipe-app.com includes the following link types:
- Recipe Pages: http://www.recipe-app.com/recipe/*
- Note Pages: http://www.recipe-app.com/recipe/*/note
- Cooking Class Registration Page: http://www.recipe-app.com/registration
- Cooking Class Schedule Page: http://www.recipe-app.com/schedule
But it could also include Cooking Class pages, using the following link types:
Note that personal content added to the on-device index does not need a corresponding webpage. To learn more about adding personal content to an on-device index for appearance in autocomplete suggestions and In Apps searches, see Enable Personal Content Indexing.
Once you've defined your structure and start creating screens in your app, remember that you also need back navigation. Users should return to the previous screen if they tap the back button after opening a link.
Add Android App Links to your app
For both public content included in Google Search results and personal content included in Google's on-device In Apps search, handle links to your app through Android App Links. Android App Links help you make sure users land in the right place when they open a link to your app. Users that don't have your app installed can also run your app without installing it through Android Instant Apps.
Android App Links include two major components:
- Deep links to your app content: Add intent filters to your manifest to define the HTTP URL mapping you set up in the step above, then configure your app to use data from the intents to send users to the right content. Learn more in Create Deep Links to App Content.
- Link verification: Configure your app to request link verification, confirming ownership of both your site and your app. Then, publish a Digital Asset Links file to your website that verifies your ownership. Learn more in Verify App Links.
The App Links Assistant in Android Studio walks you through the process outlined in the Android App Links documentation. Learn more about using the App Links Assistant.