Skip to content

Commit 8a265e3

Browse files
authoredNov 14, 2024
Merge pull request #99 from googlesamples/updatedocs
Update documentation snapshot
2 parents cff0087 + 78d309a commit 8a265e3

File tree

290 files changed

+4199
-3223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+4199
-3223
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<meta charset="utf-8">
2+
(#) Android App links should only use http(s) schemes
3+
4+
!!! ERROR: Android App links should only use http(s) schemes
5+
This is an error.
6+
7+
Id
8+
: `AppLinkSplitToWebAndCustom`
9+
Summary
10+
: Android App links should only use http(s) schemes
11+
Severity
12+
: Error
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/verify-android-applinks#add-intent-filters
27+
Implementation
28+
: [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)
29+
Tests
30+
: [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)
31+
Copyright Year
32+
: 2017
33+
34+
In order for Android App Links to open in your app, Android must perform
35+
domain verification. However, Android only sends domain verification
36+
requests for `<intent-filter>`s that only contain http(s) schemes.
37+
38+
To ensure correct behavior, please split your http(s) schemes and other
39+
schemes into two different `<intent-filter>`s.
40+
41+
!!! Tip
42+
This lint check has an associated quickfix available in the IDE.
43+
44+
(##) Example
45+
46+
Here is an example of lint warnings produced by this check:
47+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
48+
AndroidManifest.xml:7:Error: Split your http(s) and custom schemes into
49+
separate intent filters [AppLinkSplitToWebAndCustom]
50+
&lt;intent-filter android:autoVerify="true" android:order="-1" android:priority="-1"&gt;
51+
^
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53+
54+
Here are the relevant source files:
55+
56+
`AndroidManifest.xml`:
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
58+
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
59+
package="com.example.helloworld" &gt;
60+
&lt;uses-sdk android:minSdkVersion="31" android:targetSdkVersion="34" /&gt;
61+
62+
&lt;application&gt;
63+
&lt;activity android:name=".SplitWebAndCustomActivity" android:exported="true"&gt;
64+
&lt;intent-filter android:autoVerify="true" android:order="-1" android:priority="-1"&gt;
65+
&lt;action android:name="android.intent.action.VIEW" /&gt;
66+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
67+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
68+
&lt;uri-relative-filter-group&gt;
69+
&lt;data android:path="/path" /&gt;
70+
&lt;data android:query="queryparam=value" /&gt;
71+
&lt;/uri-relative-filter-group&gt;
72+
&lt;data android:scheme="http" /&gt;
73+
&lt;data android:scheme="custom" /&gt;
74+
&lt;data android:host="library.com" /&gt;
75+
&lt;data android:path="@string/path" /&gt;
76+
&lt;data android:path="/&lt;&amp;&apos;'" /&gt;
77+
&lt;data android:path='/single"quote' /&gt;
78+
&lt;data android:path="" /&gt;
79+
&lt;!-- Test having tags underneath the host elements as well --&gt;
80+
&lt;action android:name="android.intent.action.SEND"/&gt;
81+
&lt;uri-relative-filter-group&gt;
82+
&lt;data android:path="/path" /&gt;
83+
&lt;data android:query="queryparam=value" /&gt;
84+
&lt;/uri-relative-filter-group&gt;
85+
&lt;/intent-filter&gt;
86+
&lt;/activity&gt;
87+
&lt;/application&gt;
88+
&lt;/manifest&gt;
89+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90+
91+
`res/values/strings.xml`:
92+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
93+
&lt;resources&gt;
94+
&lt;string name="path"&gt;/path&lt;/string&gt;
95+
&lt;/resources&gt;
96+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97+
98+
You can also visit the
99+
[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)
100+
for the unit tests for this check to see additional scenarios.
101+
102+
The above example was automatically extracted from the first unit test
103+
found for this lint check, `AppLinksValidDetector.test_splitToWebAndCustomSchemes`.
104+
To report a problem with this extracted sample, visit
105+
https://issuetracker.google.com/issues/new?component=192708.
106+
107+
(##) Suppressing
108+
109+
You can suppress false positives using one of the following mechanisms:
110+
111+
* Adding the suppression attribute
112+
`tools:ignore="AppLinkSplitToWebAndCustom"` on the problematic XML
113+
element (or one of its enclosing elements). You may also need to add
114+
the following namespace declaration on the root element in the XML
115+
file if it's not already there:
116+
`xmlns:tools="http://schemas.android.com/tools"`.
117+
118+
```xml
119+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
120+
&lt;manifest xmlns:tools="http://schemas.android.com/tools"&gt;
121+
...
122+
&lt;activity tools:ignore="AppLinkSplitToWebAndCustom" .../&gt;
123+
...
124+
&lt;/manifest&gt;
125+
```
126+
127+
* Using a special `lint.xml` file in the source tree which turns off
128+
the check in that folder and any sub folder. A simple file might look
129+
like this:
130+
```xml
131+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
132+
&lt;lint&gt;
133+
&lt;issue id="AppLinkSplitToWebAndCustom" severity="ignore" /&gt;
134+
&lt;/lint&gt;
135+
```
136+
Instead of `ignore` you can also change the severity here, for
137+
example from `error` to `warning`. You can find additional
138+
documentation on how to filter issues by path, regular expression and
139+
so on
140+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).
141+
142+
* In Gradle projects, using the DSL syntax to configure lint. For
143+
example, you can use something like
144+
```gradle
145+
lintOptions {
146+
disable 'AppLinkSplitToWebAndCustom'
147+
}
148+
```
149+
In Android projects this should be nested inside an `android { }`
150+
block.
151+
152+
* For manual invocations of `lint`, using the `--ignore` flag:
153+
```
154+
$ lint --ignore AppLinkSplitToWebAndCustom ...`
155+
```
156+
157+
* Last, but not least, using baselines, as discussed
158+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).
159+
160+
<!-- 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>

‎docs/checks/AppLinkWarning.md.html

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
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+
&lt;intent-filter&gt; &lt;!-- We expect a warning here --&gt;
62+
-------------
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64+
65+
Here is the source file referenced above:
66+
67+
`AndroidManifest.xml`:
68+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
69+
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
70+
package="com.example.helloworld" &gt;
71+
72+
&lt;application&gt;
73+
&lt;activity android:name=".FullscreenActivity"&gt;
74+
&lt;intent-filter&gt; &lt;!-- We expect a warning here --&gt;
75+
&lt;action android:name="android.intent.action.VIEW" /&gt;
76+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
77+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
78+
79+
&lt;data android:scheme="http" /&gt;
80+
&lt;data android:scheme="https" /&gt;
81+
82+
&lt;data android:host="example.com" /&gt;
83+
&lt;data android:pathPrefix="/gizmos" /&gt;
84+
&lt;/intent-filter&gt;
85+
86+
&lt;intent-filter&gt; &lt;!-- Missing VIEW --&gt;
87+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
88+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
89+
90+
&lt;data android:scheme="http" /&gt;
91+
&lt;data android:scheme="https" /&gt;
92+
93+
&lt;data android:host="example.com" /&gt;
94+
&lt;data android:pathPrefix="/gizmos" /&gt;
95+
&lt;/intent-filter&gt;
96+
97+
&lt;intent-filter&gt; &lt;!-- Missing DEFAULT --&gt;
98+
&lt;action android:name="android.intent.action.VIEW" /&gt;
99+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
100+
101+
&lt;data android:scheme="http" /&gt;
102+
&lt;data android:scheme="https" /&gt;
103+
104+
&lt;data android:host="example.com" /&gt;
105+
&lt;data android:pathPrefix="/gizmos" /&gt;
106+
&lt;/intent-filter&gt;
107+
108+
&lt;intent-filter&gt; &lt;!-- Missing BROWSABLE --&gt;
109+
&lt;action android:name="android.intent.action.VIEW" /&gt;
110+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
111+
112+
&lt;data android:scheme="http" /&gt;
113+
&lt;data android:scheme="https" /&gt;
114+
115+
&lt;data android:host="example.com" /&gt;
116+
&lt;data android:pathPrefix="/gizmos" /&gt;
117+
&lt;/intent-filter&gt;
118+
119+
&lt;intent-filter&gt; &lt;!-- Has custom scheme, missing http --&gt;
120+
&lt;action android:name="android.intent.action.VIEW" /&gt;
121+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
122+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
123+
124+
&lt;data android:scheme="other" /&gt;
125+
126+
&lt;data android:host="example.com" /&gt;
127+
&lt;data android:pathPrefix="/gizmos" /&gt;
128+
&lt;/intent-filter&gt;
129+
130+
&lt;intent-filter&gt; &lt;!-- Has no scheme --&gt;
131+
&lt;action android:name="android.intent.action.VIEW" /&gt;
132+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
133+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
134+
135+
&lt;data android:host="example.com" /&gt;
136+
&lt;data android:pathPrefix="/gizmos" /&gt;
137+
&lt;/intent-filter&gt;
138+
139+
&lt;intent-filter&gt; &lt;!-- Missing host --&gt;
140+
&lt;action android:name="android.intent.action.VIEW" /&gt;
141+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
142+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
143+
144+
&lt;data android:scheme="http" /&gt;
145+
&lt;data android:scheme="https" /&gt;
146+
&lt;/intent-filter&gt;
147+
148+
&lt;intent-filter android:autoVerify="false"&gt; &lt;!-- We would usually expect a warning here, but it has autoVerify="false" --&gt;
149+
&lt;action android:name="android.intent.action.VIEW" /&gt;
150+
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
151+
&lt;category android:name="android.intent.category.BROWSABLE" /&gt;
152+
153+
&lt;data android:scheme="http" /&gt;
154+
&lt;data android:scheme="https" /&gt;
155+
156+
&lt;data android:host="example.com" /&gt;
157+
&lt;data android:pathPrefix="/gizmos" /&gt;
158+
&lt;/intent-filter&gt;
159+
&lt;/activity&gt;
160+
&lt;/application&gt;
161+
&lt;/manifest&gt;
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+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
185+
&lt;manifest xmlns:tools="http://schemas.android.com/tools"&gt;
186+
...
187+
&lt;activity tools:ignore="AppLinkWarning" .../&gt;
188+
...
189+
&lt;/manifest&gt;
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+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
197+
&lt;lint&gt;
198+
&lt;issue id="AppLinkWarning" severity="ignore" /&gt;
199+
&lt;/lint&gt;
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

Comments
 (0)
Failed to load comments.