Merge "docs: Deep Link and App Indexing API Support in Android Studio 1.5 b/25391753" into mnc-docs
This commit is contained in:
committed by
Android (Google) Code Review
commit
611c2e0ede
BIN
docs/html/images/tools/ai-ilightbulb.png
Normal file
BIN
docs/html/images/tools/ai-ilightbulb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
BIN
docs/html/images/tools/ai-lint.png
Normal file
BIN
docs/html/images/tools/ai-lint.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
@@ -32,6 +32,7 @@ parent.link=index.html
|
||||
Using the Android Emulator</a></li>
|
||||
<li><a href="{@docRoot}tools/publishing/app-signing.html">
|
||||
Signing Your Applications</a></li>
|
||||
<li><a href="{@docRoot}tools/help/app-link-indexing.html">Deep Link and App Indexing API Support in Android Studio</a></li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
|
||||
514
docs/html/tools/help/app-link-indexing.jd
Normal file
514
docs/html/tools/help/app-link-indexing.jd
Normal file
@@ -0,0 +1,514 @@
|
||||
page.title=Deep Link and App Indexing API Support in Android Studio
|
||||
parent.title=Tools
|
||||
parent.link=index.html
|
||||
page.tags=app indexing
|
||||
@jd:body
|
||||
|
||||
<div id="qv-wrapper">
|
||||
<div id="qv">
|
||||
<h2>In this document</h2>
|
||||
<ol>
|
||||
<li><a href="#workflow">Typical Workflow</a></li>
|
||||
<li><a href="#intent">Adding an Intent Filter for Deep Linking and Google Search</a></li>
|
||||
<li><a href="#indexing">Adding App Indexing API Skeleton Code to an Activity</a></li>
|
||||
<li><a href="#testintent">Testing a Deep Link</a></li>
|
||||
<li><a href="#testindexing">Viewing App Indexing API Messages in the logcat Monitor</a></li>
|
||||
<li><a href="#lint">Configuring Lint</a></li>
|
||||
</ol>
|
||||
|
||||
<h2>See also</h2>
|
||||
<ol>
|
||||
<li><a href="https://developers.google.com/app-indexing/introduction"
|
||||
class="external-link">App Indexing</a></li>
|
||||
<li><a href="{@docRoot}training/app-indexing/index.html"
|
||||
>Making Your App Content Searchable by Google</a></li>
|
||||
<li><a href="{@docRoot}training/app-links/index.html">Handling App Links</a></li>
|
||||
<li><a href="{@docRoot}tools/debugging/improving-w-lint.html"
|
||||
>Improving Your Code with lint</a></li>
|
||||
<li><a href="{@docRoot}tools/help/am-logcat.html">logcat Monitor</a></li>
|
||||
<li><a href="https://www.google.com/webmasters/tools/home"
|
||||
class="external-link">Google Search Console</a></li>
|
||||
<li><a href="https://developers.google.com/android/guides/overview"
|
||||
class="external-link">Google Play Services</a></li>
|
||||
</ol>
|
||||
|
||||
<h2>Video</h2>
|
||||
<ol>
|
||||
<li><a href="https://www.youtube.com/watch?v=aISUYHTkTOU"
|
||||
class="external-link">DevBytes: App Indexing</a></li>
|
||||
</ol>
|
||||
|
||||
<h2>Dependencies and prerequisites</h2>
|
||||
<ul>
|
||||
<li>Android 2.3 (API level 9) or higher</li>
|
||||
<li>Android Studio 1.5 or higher</li>
|
||||
<li>Google Play Services 8.1.0 or higher</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Android Studio helps you add deep links, app indexing, and search functionality to your apps.
|
||||
These features can help to drive more traffic to your
|
||||
app, discover which app content is used most, make it easier for users to find content in an
|
||||
installed app, and attract new users.</p>
|
||||
|
||||
<h2 id="workflow">Typical Workflow</h2>
|
||||
|
||||
<p>To use Android Studio to add deep link, app indexing, and search features to your app, follow
|
||||
these basic steps:</p>
|
||||
|
||||
<ol>
|
||||
<li>Add intent filters and code to handle incoming intents.</li>
|
||||
<li>Associate a website with your app.</li>
|
||||
<li>Add App Indexing API code.</li>
|
||||
</ol>
|
||||
|
||||
<p>Intent filters and the App Indexing API are ways to implement deep links and app indexing, but
|
||||
there are other possible implementations as well. See
|
||||
<a href="https://developers.google.com/app-indexing/reference/deeplinks"
|
||||
class="external-link">Alternate Android Indexing Methods</a>
|
||||
for more information.</p>
|
||||
|
||||
<h3 id="aboutintent">Intent filters for deep links</h3>
|
||||
|
||||
<p>Android Studio can create a basic intent filter in your manifest that you can customize to
|
||||
define deep link URLs for your app. You can then write Java code in an activity to handle the
|
||||
intent. This implementation lets users directly open the specified app activity by
|
||||
clicking a deep link. Users can see the deep links in google.com in a browser, in the
|
||||
Google Search app, and in Google Now on Tap. </p>
|
||||
|
||||
<h3 id="aboutassociation">Website association with deep links</h3>
|
||||
|
||||
<p>After setting up deep links for your app, you can associate your website with your app by using
|
||||
the Google Search Console and Google Play Developer Console. Afterward, Google indexes your app
|
||||
for URLs defined in
|
||||
your intent filters and begins to include them in search results. In addition, you can optionally
|
||||
exclude app content from Google Search. After you associate a website with your app, features
|
||||
such as Now on Tap and enhanced search result display (like including your app icon)
|
||||
become available.</p>
|
||||
|
||||
<p>As an alternative to associating your app with a website,
|
||||
for Android 6.0 (API level 23) and higher, you can add
|
||||
<a href="{@docRoot}training/app-links/index.html"
|
||||
>default handlers and verification for deep links</a>
|
||||
instead.</p>
|
||||
|
||||
<p>Chrome displaying google.com serves search results with deep links that are accessible to both
|
||||
signed-in users and those who aren't. Google Search app users must be signed in to see deep links
|
||||
in their search results. </p>
|
||||
|
||||
<h3 id="aboutapi">App Indexing API code in activities</h3>
|
||||
|
||||
<p>Next, if you want to support additional search features, such as autocompletions, you can
|
||||
add App Indexing API code to your app. Android Studio can create skeleton code in an activity
|
||||
that you can then customize to support app indexing. The App Indexing API allows app indexing
|
||||
even if
|
||||
<a href="https://developers.google.com/app-indexing/reference/deeplinks#allow-access-by-googlebot-optional"
|
||||
class="external-link">Googlebot</a>
|
||||
can’t get content from your app.</p>
|
||||
|
||||
<h3 id="abouttest">Deep link and App Indexing API testing</h3>
|
||||
|
||||
<p>Android Studio helps you test your code with the following features:</p>
|
||||
|
||||
<ul>
|
||||
<li>Deep link testing helps you verify that a specified deep link can launch an app. </li>
|
||||
<li>The logcat Monitor helps you test App Indexing API calls in an activity. </li>
|
||||
<li>The Android Lint tool has warnings for certain issues involving deep links and the App Indexing
|
||||
API. These warnings and errors appear in the Code Editor and in Lint inspection results.</li>
|
||||
</ul>
|
||||
|
||||
<p>The details for implementing deep links and app indexing are described next.
|
||||
|
||||
|
||||
<h2 id="intent">Adding an Intent Filter for Deep Linking and Google Search</h2>
|
||||
|
||||
<p>To use Android Studio features to add an intent filter defining a deep link, follow these
|
||||
steps:</p>
|
||||
|
||||
<ol>
|
||||
<li>In the <a href="{@docRoot}sdk/installing/create-project.html#ProjectView">Android view</a>
|
||||
of the <em>Project</em> window, double-click the <code>AndroidManifest.xml</code> file to open it
|
||||
in the Code Editor.</li>
|
||||
<li>Insert an intent filter in one of the following ways:</li>
|
||||
<ul>
|
||||
<li>In an <code><activity></code> element, click in the left column so the light bulb
|
||||
<img src="{@docRoot}images/tools/ai-ilightbulb.png"
|
||||
style="vertical-align:sub;margin:0;height:17px" alt="Lightbulb icon" /> appears. Click
|
||||
<img src="{@docRoot}images/tools/ai-ilightbulb.png"
|
||||
style="vertical-align:sub;margin:0;height:17px" alt="Lightbulb icon" />
|
||||
and select <strong>Create Deep Link</strong>.</li>
|
||||
<li>Right-click in an <code><activity></code> element and select <strong>Generate</strong>
|
||||
> <strong>Deep Link</strong>.</li>
|
||||
<li>Place your cursor in an activity, and then select <strong>Code</strong> >
|
||||
<strong>Generate</strong> > <strong>Deep Link</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<p>The Code Editor adds skeleton code using the
|
||||
<a href="https://www.jetbrains.com/idea/help/intention-actions.html"
|
||||
class="external-link">intention action</a> and
|
||||
<a href="https://www.jetbrains.com/idea/help/generating-code.html"
|
||||
class="external-link">generate code</a> mechanisms.</p>
|
||||
|
||||
<p>The Code Editor adds an intent filter similar to the following:</p>
|
||||
<pre>
|
||||
<!-- ATTENTION: This intent was auto-generated. Follow instructions at
|
||||
https://g.co/AppIndexing/AndroidStudio to publish your Android app deep links. -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<!-- ATTENTION: This data URL was auto-generated.
|
||||
We recommend that you use the HTTP scheme.
|
||||
TODO: Change the host or pathPrefix as necessary. -->
|
||||
<data
|
||||
android:host="www.example.com"
|
||||
android:pathPrefix="/gizmos"
|
||||
android:scheme="http" />
|
||||
</intent-filter>
|
||||
</pre>
|
||||
|
||||
<li><a href="{@docRoot}training/app-indexing/deep-linking.html#adding-filters">Modify the
|
||||
<code><data></code> element</a>
|
||||
and optionally the <code><category></code> element, as needed.</li>
|
||||
|
||||
|
||||
<p>We recommend that you define a <code><data></code> element that supports URLs that you’ll
|
||||
add in the future. In the previous sample code, for example, Google will index any URLs starting
|
||||
with <code>www.example.com/gizmos</code>. Also, remember to
|
||||
include a deep link for your app home screen so it’s included in search results. </p>
|
||||
|
||||
<p>Deep link URLs can be the same as the URLs of the comparable pages on your website.</p>
|
||||
|
||||
<li>In the corresponding activity,
|
||||
<a href="{@docRoot}training/app-indexing/deep-linking.html#handling-intents">add Java code</a>
|
||||
to read data from the intent filter and direct the app to respond accordingly. </li>
|
||||
<li><a href="#testintent">Test your deep link</a>.</li>
|
||||
|
||||
</ol>
|
||||
|
||||
<p>To support Google Search for your deep links, follow these steps:</p>
|
||||
<ol>
|
||||
<li><a href="https://developers.google.com/app-indexing/android/app#declare-a-website-association"
|
||||
class="external-link">Define an association</a>
|
||||
between your app and your website.</li>
|
||||
<p>Alternatively, for Android 6.0 (API level 23) and higher, add
|
||||
<a href="{@docRoot}training/app-links/index.html">link default handling and verification</a>.</p>
|
||||
<li>Optionally
|
||||
<a href="https://developers.google.com/app-indexing/android/app#create-the-noindexxml-file"
|
||||
class="external-link">exclude app URLs</a>
|
||||
from the Google index.</li>
|
||||
<li>Optionally <a href="#indexing">add App Indexing API code</a> to support additional search
|
||||
features.</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<p>To test and debug your links, you can use the following Android Studio features:</p>
|
||||
<ul>
|
||||
<li><a href="#testintent">Launch your deep link</a> in Android Studio to test that it works.</li>
|
||||
<li><a href="#lint">Enable the following Android Lint categories</a>:</li>
|
||||
<ul>
|
||||
<li><strong>Missing Support for Google App Indexing</strong></li>
|
||||
<li><strong>Incorrect Usage of App Link for Google App Indexing</strong></li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<p>In addition, you can
|
||||
<a href="https://developers.google.com/app-indexing/android/test#preview-your-apk-on-search-console"
|
||||
class="external-link">preview your APK in the Google Search Console</a>
|
||||
to test your deep links, whether the app is associated with a website or not. </p>
|
||||
|
||||
|
||||
|
||||
<h2 id="indexing">Adding App Indexing API Skeleton Code to an Activity</h2>
|
||||
|
||||
<p>After adding deep links, you can add App Indexing API code to an activity to support additional
|
||||
search features. </p>
|
||||
|
||||
<p>To add App Indexing API code to an activity, follow these steps:</p>
|
||||
<ol>
|
||||
<li>In <a href="{@docRoot}sdk/installing/create-project.html#ProjectView">Android view</a>
|
||||
in the <em>Project</em> window, double-click the activity Java file to open it in the
|
||||
Code Editor.</li>
|
||||
<li>Insert skeleton code in one of the following ways:</li>
|
||||
<ul>
|
||||
<li>In an activity definition, click in the Java code so the light bulb
|
||||
<img src="{@docRoot}images/tools/ai-ilightbulb.png"
|
||||
style="vertical-align:sub;margin:0;height:17px" alt="Lightbulb icon" /> appears.
|
||||
Click <img src="{@docRoot}images/tools/ai-ilightbulb.png"
|
||||
style="vertical-align:sub;margin:0;height:17px" alt="Lightbulb icon" />
|
||||
and select <strong>Insert App Indexing API Code</strong>.</li>
|
||||
<li>Right-click in an activity definition and select <strong>Generate</strong> >
|
||||
<strong>App Indexing API Code</strong>.</li>
|
||||
<li>Place the cursor in an activity, and then select <strong>Code</strong> >
|
||||
<strong>Generate</strong> >
|
||||
<strong>App Indexing API Code</strong>.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The Code Editor adds skeleton code using the
|
||||
<a href="https://www.jetbrains.com/idea/help/intention-actions.html"
|
||||
class="external-link">intention action</a> and
|
||||
<a href="https://www.jetbrains.com/idea/help/generating-code.html"
|
||||
class="external-link">generate code</a>
|
||||
mechanisms.</p>
|
||||
|
||||
<p>If you don’t see the <strong>App Indexing API Code</strong> menu item, make sure your cursor is
|
||||
within an activity, and check your code for App Indexing API methods. The Code Editor can insert
|
||||
skeleton Java code into an activity in the following circumstances:</p>
|
||||
|
||||
<ul>
|
||||
<li>The activity doesn’t have an <code>onStart()</code> method, or the <code>onStart()</code>
|
||||
method doesn’t contain an <code>AppIndexApi.start()</code> or <code>AppIndexApi.view()</code>
|
||||
call.</li>
|
||||
<li>The activity doesn’t have an <code>onStop()</code> method, or the <code>onStop()</code>
|
||||
method doesn’t contain an <code>AppIndexApi.end()</code> or <code>AppIndexApi.viewEnd()</code>
|
||||
call.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The Code Editor adds Java code similar to the following:</p>
|
||||
<pre>
|
||||
/**
|
||||
* ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
* See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
*/
|
||||
private GoogleApiClient client;
|
||||
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
client.connect();
|
||||
Action viewAction = Action.newAction(
|
||||
Action.TYPE_VIEW, // TODO: choose an action type.
|
||||
"Main Page", // TODO: Define a title for the content shown.
|
||||
// TODO: If you have web page content that matches
|
||||
// this app activity's content,
|
||||
// make sure this auto-generated web page URL is correct.
|
||||
// Otherwise, set the URL to null.
|
||||
Uri.parse("http://host/path"),
|
||||
// TODO: Make sure this auto-generated app deep link URI is correct.
|
||||
Uri.parse("android-app://com.example/http/host/path")
|
||||
);
|
||||
AppIndex.AppIndexApi.start(client, viewAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
Action viewAction = Action.newAction(
|
||||
Action.TYPE_VIEW, // TODO: choose an action type.
|
||||
"Main Page", // TODO: Define a title for the content shown.
|
||||
// TODO: If you have web page content that matches
|
||||
// this app activity's content,
|
||||
// make sure this auto-generated web page URL is correct.
|
||||
// Otherwise, set the URL to null.
|
||||
Uri.parse("http://host/path"),
|
||||
// TODO: Make sure this auto-generated app deep link URI is correct.
|
||||
Uri.parse("android-app://com.example/http/host/path")
|
||||
);
|
||||
AppIndex.AppIndexApi.end(client, viewAction);
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>For more information about the App Indexing API methods, see
|
||||
<a href="https://developers.google.com/app-indexing/reference/package-summary"
|
||||
class="external-link">Android API for App Indexing</a>.
|
||||
For information about the action types, see the
|
||||
<a href="https://developers.google.com/android/reference/com/google/android/gms/appindexing/Action#constant-summary"
|
||||
class="external-link">Action Class Constant Summary</a>.
|
||||
</p>
|
||||
|
||||
<p>If your app isn’t already configured for the Google Play Services App Indexing API, the Code
|
||||
Editor also modifies your <code>build.gradle</code> and <code>AndroidManifest.xml</code> files
|
||||
to include it. If your app already depends on it but the version is lower than 8.1.0, your app
|
||||
is upgraded to version 8.1.0. For more information and to correct any issues, see
|
||||
<a href="https://developers.google.com/app-indexing/android/publish#add-google-play-services"
|
||||
class="external-link">Add Google Play Services</a>
|
||||
and <a href="https://developers.google.com/android/guides/setup"
|
||||
class="external-link">Setting Up Google Play Services</a>.
|
||||
</p>
|
||||
|
||||
<li>Customize the skeleton code, as needed.</li>
|
||||
|
||||
<p>Pay attention to the comments, which help you find areas that need work, such as setting the
|
||||
title and URLs. For more information, see
|
||||
<a href="https://developers.google.com/app-indexing/android/publish"
|
||||
class="external-link">Add the App Indexing API</a>.
|
||||
</p>
|
||||
<li><a href="#testindexing">Verify that your app indexing code is working</a> by using
|
||||
the logcat Monitor.</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<p>To test and debug your App Indexing API code, you can use the following Android Studio
|
||||
features:</p>
|
||||
<ul>
|
||||
<li><a href="#testindexing">Examine logcat Monitor Messages</a>.</li>
|
||||
<li><a href="#lint">Enable the following Android Lint category</a>:
|
||||
<strong>Missing Support for Google App Indexing API</strong></li>
|
||||
</ul>
|
||||
|
||||
<p>In addition, you can
|
||||
<a href="https://developers.google.com/app-indexing/android/test#preview-your-apk-on-search-console"
|
||||
class="external-link">preview your APK in the Google Search Console</a>.</p>
|
||||
|
||||
|
||||
<h2 id="testintent">Testing a Deep Link</h2>
|
||||
|
||||
<p>When you run your app from Android Studio, you can specify a deep link to launch so you can
|
||||
test it.</p>
|
||||
|
||||
<p>To launch a deep link from Android Studio, follow these steps:</p>
|
||||
<ol>
|
||||
<li>In Android Studio, open your project in
|
||||
<a href="{@docRoot}sdk/installing/create-project.html#ProjectView">Android view</a>.</li>
|
||||
<li>After opening a project, select <strong>Run</strong> > <strong>Edit Configurations</strong>.
|
||||
</li>
|
||||
<li>In the <em>Run/Debug Configurations</em> dialog, beneath <strong>Android Application,</strong>
|
||||
select the module you want to test.</li>
|
||||
<li>Select the <strong>General</strong> tab. </li>
|
||||
<li>In the <strong>Launch</strong> field, select <strong>Deep Link</strong>. </li>
|
||||
<li>In the <strong>Deep Link</strong> field, click <strong>…</strong> to select from a list of
|
||||
defined deep links.</li>
|
||||
|
||||
<p>Or type the URL you want to test, for example, <code>http://example.com/gizmos</code>. </p>
|
||||
<li>Click <strong>OK</strong>.</li>
|
||||
<li>Select <strong>Run</strong> > <strong>Run app</strong> or <strong>Debug app</strong>.</li>
|
||||
<li>If the <em>Device Chooser</em> dialog appears, select a connected device or an
|
||||
emulator, and click <strong>OK</strong>.</li>
|
||||
|
||||
<p>If the link is successful, the app launches in the device or emulator, and displays the app at
|
||||
the specified activity. Otherwise, an error message appears in the <em>Run</em> window.</p>
|
||||
</ol>
|
||||
|
||||
<p>For more information about creating run configurations at the project, default, and module
|
||||
levels, see
|
||||
<a href="{@docRoot}tools/building/building-studio.html">Building and Running from Android Studio</a>.
|
||||
</p>
|
||||
|
||||
<p>You can view App Indexing API log messages while the app is running, as described next.</p>
|
||||
|
||||
|
||||
<h2 id="testindexing">Viewing App Indexing API Messages in the logcat Monitor</h2>
|
||||
|
||||
<p>The logcat Monitor can display app indexing log messages to determine if your App Indexing API
|
||||
code is pushing the correct data to the cloud. For example, you can check the app title and the
|
||||
URL. The logcat Monitor is part of Android Monitor in Android Studio. </p>
|
||||
|
||||
<p>Follow these steps:</p>
|
||||
<ol>
|
||||
<li>Run your app in Android Studio so it <a href="#testintent">launches a deep link</a>.</li>
|
||||
<li><a href="{@docRoot}tools/help/android-monitor.html#displaying">Display Android Monitor</a>
|
||||
and click the <strong>logcat</strong> tab.</li>
|
||||
<li><a href="{@docRoot}tools/help/am-logcat.html#level">Set the log level</a> to
|
||||
<strong>Verbose</strong>.</li>
|
||||
<li>In the filter menu, select <strong>No Filters</strong>.</li>
|
||||
<li><a href="{@docRoot}tools/help/am-logcat.html#searching">Search the log</a> for the string
|
||||
"appindex".</li>
|
||||
|
||||
<p>App indexing log messages should appear. If they don’t, check the following items:</p>
|
||||
<ul>
|
||||
<li>Is Google Play Services installed on the device or emulator? You can check the settings on
|
||||
the device. </li>
|
||||
<li>Is the Google Play Services version on the device or emulator lower than the version specified
|
||||
in the <code>build.gradle</code> file? If so, it might be out-of-date and should be upgraded to
|
||||
a higher version. </li>
|
||||
</ul>
|
||||
|
||||
<p>For more information, see the
|
||||
<a href="https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en"
|
||||
class="external-link">Google Play Services Download</a>
|
||||
page and <a href="https://developers.google.com/android/guides/setup"
|
||||
class="external-link">Setting Up Google Play Services</a>.
|
||||
</p>
|
||||
<li>Visit app pages that trigger App Indexing API calls. </li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h2 id="lint">Configuring Lint</h2>
|
||||
|
||||
<p>You can use the Android Studio built-in Lint tool to check whether you have valid deep links
|
||||
defined in the manifest and have implemented the App Indexing API correctly in activities.</p>
|
||||
|
||||
<p>You can view deep link and app indexing warnings and errors in two ways: </p>
|
||||
<ul>
|
||||
<li>As pop-up text in the Code Editor. When Lint finds a problem, it highlights the problematic
|
||||
code in yellow, or underlines the code in red for more serious issues.</li>
|
||||
<li>In the Lint <em>Inspection Results</em> window after you select <strong>Analyze</strong> >
|
||||
<strong>Inspect Code</strong>.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<p>To set default Lint checks for deep links and the App Indexing API, follow these steps:</p>
|
||||
<ol>
|
||||
<li>In Android Studio, open your project in
|
||||
<a href="{@docRoot}sdk/installing/create-project.html#ProjectView">Android view</a>.
|
||||
</li>
|
||||
<li>Select <strong>File</strong> > <strong>Other Settings</strong> >
|
||||
<strong>Default Settings</strong>.</li>
|
||||
<li>In the <em>Default Preferences</em> dialog, select <strong>Editor</strong> >
|
||||
<strong>Inspections</strong>. </li>
|
||||
<li>In the <strong>Profile</strong> field, select <strong>Default</strong> or
|
||||
<strong>Project Default</strong> to set the scope for Android Studio or just for this project,
|
||||
respectively. </li>
|
||||
<li>Expand the <strong>Android Lint</strong> category and change the Lint settings as needed:</li>
|
||||
<ul>
|
||||
<li><strong>Missing Support for Google App Indexing</strong> - Reports a warning if the app hasn’t
|
||||
implemented deep links, which are used by Google Search. This warning setting is enabled by
|
||||
default.</li>
|
||||
<li><strong>Missing Support for Google App Indexing API</strong> - Reports if an app hasn’t
|
||||
implemented the App Indexing API at all. This warning setting is disabled by default.</li>
|
||||
<li><strong>Incorrect Usage of App Link for Google App Indexing</strong> - Reports deep link
|
||||
errors in manifest code. This error setting is enabled by default.</li>
|
||||
</ul>
|
||||
|
||||
<p>For example, the following Lint warning appears for the first setting:</p>
|
||||
<p><img src="{@docRoot}images/tools/ai-lint.png" /></p>
|
||||
|
||||
<li>Click <strong>OK</strong>.</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<p>To produce a list of Lint checks displayed in the <em>Inspection Results</em> window,
|
||||
follow these steps:</p>
|
||||
<ol>
|
||||
<li>In Android Studio, open your project in
|
||||
<a href="{@docRoot}sdk/installing/create-project.html#ProjectView">Android view</a>
|
||||
and select a portion of your project that you want to test.</li>
|
||||
<li>Select <strong>Analyze</strong> > <strong>Inspect Code</strong>.</li>
|
||||
<li>In the <em>Specify Inspection Scope </em>dialog, select the inspection scope and profile. </li>
|
||||
|
||||
<p>The scope specifies the files you want to analyze, and the profile specifies the Lint checks
|
||||
you’d like to perform.</p>
|
||||
<li>If you want to change the Lint settings, click <strong>…</strong>. In the <em>Inspections</em>
|
||||
dialog, optionally click <strong>Manage</strong> to define a new profile, specify the Lint
|
||||
settings you want, and then click <strong>OK</strong>.</li>
|
||||
<p>In the <em>Inspections</em> dialog, you can search for the string "app indexing"
|
||||
to find the deep link and App Indexing API Lint checks. Note that changing Lint settings for a
|
||||
profile in the <em>Inspections</em> dialog doesn’t change the default settings, as described in
|
||||
the previous procedure. It does change the settings for profiles displayed in the
|
||||
<em>Inspections</em> dialog, however.</p>
|
||||
<li>Click <strong>OK</strong>.</li>
|
||||
<p>The results appear in the <em>Inspection Results</em> window.</p>
|
||||
|
||||
</ol>
|
||||
@@ -43,6 +43,11 @@ avd</code>) the emulator (<code>emulator</code>), and the Dalvik Debug Monitor S
|
||||
<dt><a href="{@docRoot}tools/help/android.html">android</a></dt>
|
||||
<dd>Lets you manage AVDs, projects, and the installed components of the SDK.</dd>
|
||||
|
||||
<dt><a href="{@docRoot}tools/help/app-link-indexing.html">Deep Link and App Indexing API Support</a></dt>
|
||||
<dd>Helps you add deep links, app indexing, and search functionality to your apps.
|
||||
These features can make it easier to find content in an installed app, drive more traffic to your
|
||||
app, discover which app content is used most, and attract new users.</dd>
|
||||
|
||||
<dt><a href="{@docRoot}tools/help/hierarchy-viewer.html">Hierarchy Viewer (hierarchyviewer)</a></dt>
|
||||
<dd>Provides a visual representation of the layout's View hierarchy with performance information
|
||||
for each node in the layout, and a magnified view of the display to closely examine the
|
||||
@@ -139,7 +144,7 @@ content is allowed.</dd>
|
||||
|
||||
<dt><a href="{@docRoot}tools/help/image-asset-studio.html">Image Asset Studio</a></dt>
|
||||
<dd>Helps you to generate custom icons for your Android applications from existing images, cliparts, or text.
|
||||
It generates a set of icons at the appropriate resolution for each generalized screen density that your app
|
||||
It generates a set of icons at the appropriate resolution for each generalized screen density that your app
|
||||
supports.</dd>
|
||||
|
||||
<dt><a href="{@docRoot}tools/help/vector-asset-studio.html">Vector Asset Studio</a></dt>
|
||||
|
||||
@@ -146,8 +146,9 @@ class="en">Tools Help</span></a></div>
|
||||
</li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/avd-manager.html">AVD Manager</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/bmgr.html">bmgr</a>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/monitor.html">Device Monitor</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/app-link-indexing.html">Deep Link and App Indexing API Support</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/desktop-head-unit.html">Desktop Head Unit</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/monitor.html">Device Monitor</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/dmtracedump.html">dmtracedump</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/draw9patch.html">Draw 9-Patch</a></li>
|
||||
<li><a href="<?cs var:toroot ?>tools/help/emulator.html">Emulator</a></li>
|
||||
|
||||
@@ -22,6 +22,7 @@ startpage=true
|
||||
target="_blank">App Indexing for Google Search</a></li>
|
||||
<li><a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent
|
||||
Filters</a></li>
|
||||
<li><a href="{@docRoot}tools/help/app-link-indexing.html">Deep Link and App Indexing API Support in Android Studio</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,10 @@ page.tags=androidm,marshmallow
|
||||
<li><a href="#web-assoc">Declare Website Associations</a></li>
|
||||
<li><a href="#testing">Test App Links</a></li>
|
||||
</ol>
|
||||
<h2>See also</h2>
|
||||
<ol>
|
||||
<li><a href="{@docRoot}tools/help/app-link-indexing.html">Deep Link and App Indexing API Support in Android Studio</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user