1
+ < meta charset ="utf-8 ">
2
+ (#) App Link warning
3
+
4
+ !!! WARNING: App Link warning
5
+ This is a warning.
6
+
7
+ Id
8
+ : `AppLinkWarning`
9
+ Summary
10
+ : App Link warning
11
+ Severity
12
+ : Warning
13
+ Category
14
+ : Correctness
15
+ Platform
16
+ : Android
17
+ Vendor
18
+ : Android Open Source Project
19
+ Feedback
20
+ : https://issuetracker.google.com/issues/new?component=192708
21
+ Affects
22
+ : Manifest files
23
+ Editing
24
+ : This check runs on the fly in the IDE editor
25
+ See
26
+ : https://developer.android.com/training/app-links
27
+ See
28
+ : https://g.co/AppIndexing/AndroidStudio
29
+ Implementation
30
+ : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/AppLinksValidDetector.kt)
31
+ Tests
32
+ : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/AppLinksValidDetectorTest.kt)
33
+ Copyright Year
34
+ : 2017
35
+
36
+ From Android 12, intent filters that use the HTTP and HTTPS schemes will
37
+ no longer bring the user to your app when the user clicks
38
+ a link, unless the intent filter is an Android App Link.
39
+ Such intent filters must include certain elements, and at least
40
+ one Android App Link for each domain must have
41
+ `android:autoVerify="true"` to verify ownership of the
42
+ domain. We recommend adding `android:autoVerify="true"` to any intent
43
+ filter that is intended to be an App Link, in case the other
44
+ App Links are modified.
45
+
46
+ !!! Tip
47
+ This lint check has an associated quickfix available in the IDE.
48
+
49
+ (##) Example
50
+
51
+ Here is an example of lint warnings produced by this check:
52
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
53
+ AndroidManifest.xml:6:Warning: This intent filter has the format of an
54
+ Android App Link but is missing the autoVerify attribute; add
55
+ android:autoVerify="true" to ensure your domain will be validated and
56
+ enable App Link-related Lint warnings. If you do not want clicked URLs
57
+ to bring the user to your app, remove the
58
+ android.intent.category.BROWSABLE category, or set
59
+ android:autoVerify="false" to make it clear this is not intended to be
60
+ an Android App Link. [AppLinkWarning]
61
+ <intent-filter> <!-- We expect a warning here -->
62
+ -------------
63
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
+
65
+ Here is the source file referenced above:
66
+
67
+ `AndroidManifest.xml`:
68
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
69
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
70
+ package="com.example.helloworld" >
71
+
72
+ <application>
73
+ <activity android:name=".FullscreenActivity">
74
+ <intent-filter> <!-- We expect a warning here -->
75
+ <action android:name="android.intent.action.VIEW" />
76
+ <category android:name="android.intent.category.DEFAULT" />
77
+ <category android:name="android.intent.category.BROWSABLE" />
78
+
79
+ <data android:scheme="http" />
80
+ <data android:scheme="https" />
81
+
82
+ <data android:host="example.com" />
83
+ <data android:pathPrefix="/gizmos" />
84
+ </intent-filter>
85
+
86
+ <intent-filter> <!-- Missing VIEW -->
87
+ <category android:name="android.intent.category.DEFAULT" />
88
+ <category android:name="android.intent.category.BROWSABLE" />
89
+
90
+ <data android:scheme="http" />
91
+ <data android:scheme="https" />
92
+
93
+ <data android:host="example.com" />
94
+ <data android:pathPrefix="/gizmos" />
95
+ </intent-filter>
96
+
97
+ <intent-filter> <!-- Missing DEFAULT -->
98
+ <action android:name="android.intent.action.VIEW" />
99
+ <category android:name="android.intent.category.BROWSABLE" />
100
+
101
+ <data android:scheme="http" />
102
+ <data android:scheme="https" />
103
+
104
+ <data android:host="example.com" />
105
+ <data android:pathPrefix="/gizmos" />
106
+ </intent-filter>
107
+
108
+ <intent-filter> <!-- Missing BROWSABLE -->
109
+ <action android:name="android.intent.action.VIEW" />
110
+ <category android:name="android.intent.category.DEFAULT" />
111
+
112
+ <data android:scheme="http" />
113
+ <data android:scheme="https" />
114
+
115
+ <data android:host="example.com" />
116
+ <data android:pathPrefix="/gizmos" />
117
+ </intent-filter>
118
+
119
+ <intent-filter> <!-- Has custom scheme, missing http -->
120
+ <action android:name="android.intent.action.VIEW" />
121
+ <category android:name="android.intent.category.DEFAULT" />
122
+ <category android:name="android.intent.category.BROWSABLE" />
123
+
124
+ <data android:scheme="other" />
125
+
126
+ <data android:host="example.com" />
127
+ <data android:pathPrefix="/gizmos" />
128
+ </intent-filter>
129
+
130
+ <intent-filter> <!-- Has no scheme -->
131
+ <action android:name="android.intent.action.VIEW" />
132
+ <category android:name="android.intent.category.DEFAULT" />
133
+ <category android:name="android.intent.category.BROWSABLE" />
134
+
135
+ <data android:host="example.com" />
136
+ <data android:pathPrefix="/gizmos" />
137
+ </intent-filter>
138
+
139
+ <intent-filter> <!-- Missing host -->
140
+ <action android:name="android.intent.action.VIEW" />
141
+ <category android:name="android.intent.category.DEFAULT" />
142
+ <category android:name="android.intent.category.BROWSABLE" />
143
+
144
+ <data android:scheme="http" />
145
+ <data android:scheme="https" />
146
+ </intent-filter>
147
+
148
+ <intent-filter android:autoVerify="false"> <!-- We would usually expect a warning here, but it has autoVerify="false" -->
149
+ <action android:name="android.intent.action.VIEW" />
150
+ <category android:name="android.intent.category.DEFAULT" />
151
+ <category android:name="android.intent.category.BROWSABLE" />
152
+
153
+ <data android:scheme="http" />
154
+ <data android:scheme="https" />
155
+
156
+ <data android:host="example.com" />
157
+ <data android:pathPrefix="/gizmos" />
158
+ </intent-filter>
159
+ </activity>
160
+ </application>
161
+ </manifest>
162
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163
+
164
+ You can also visit the
165
+ [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/AppLinksValidDetectorTest.kt)
166
+ for the unit tests for this check to see additional scenarios.
167
+
168
+ The above example was automatically extracted from the first unit test
169
+ found for this lint check, `AppLinksValidDetector.testAddAutoVerifySuggestion`.
170
+ To report a problem with this extracted sample, visit
171
+ https://issuetracker.google.com/issues/new?component=192708.
172
+
173
+ (##) Suppressing
174
+
175
+ You can suppress false positives using one of the following mechanisms:
176
+
177
+ * Adding the suppression attribute `tools:ignore="AppLinkWarning"` on
178
+ the problematic XML element (or one of its enclosing elements). You
179
+ may also need to add the following namespace declaration on the root
180
+ element in the XML file if it's not already there:
181
+ `xmlns:tools="http://schemas.android.com/tools"`.
182
+
183
+ ```xml
184
+ <?xml version="1.0" encoding="UTF-8"?>
185
+ <manifest xmlns:tools="http://schemas.android.com/tools">
186
+ ...
187
+ <activity tools:ignore="AppLinkWarning" .../>
188
+ ...
189
+ </manifest>
190
+ ```
191
+
192
+ * Using a special `lint.xml` file in the source tree which turns off
193
+ the check in that folder and any sub folder. A simple file might look
194
+ like this:
195
+ ```xml
196
+ <?xml version="1.0" encoding="UTF-8"?>
197
+ <lint>
198
+ <issue id="AppLinkWarning" severity="ignore" />
199
+ </lint>
200
+ ```
201
+ Instead of `ignore` you can also change the severity here, for
202
+ example from `error` to `warning`. You can find additional
203
+ documentation on how to filter issues by path, regular expression and
204
+ so on
205
+ [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).
206
+
207
+ * In Gradle projects, using the DSL syntax to configure lint. For
208
+ example, you can use something like
209
+ ```gradle
210
+ lintOptions {
211
+ disable 'AppLinkWarning'
212
+ }
213
+ ```
214
+ In Android projects this should be nested inside an `android { }`
215
+ block.
216
+
217
+ * For manual invocations of `lint`, using the `--ignore` flag:
218
+ ```
219
+ $ lint --ignore AppLinkWarning ...`
220
+ ```
221
+
222
+ * Last, but not least, using baselines, as discussed
223
+ [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).
224
+
225
+ <!-- Markdeep: --> < style class ="fallback "> body {visibility : hidden;white-space : pre;font-family : monospace}</ style > < script src ="markdeep.min.js " charset ="utf-8 "> </ script > < script src ="https://morgan3d.github.io/markdeep/latest/markdeep.min.js " charset ="utf-8 "> </ script > < script > window . alreadyProcessedMarkdeep || ( document . body . style . visibility = "visible" ) </ script >
0 commit comments