Skip to content

Commit 8a265e3

Browse files
authored
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
Lines changed: 160 additions & 0 deletions
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+
<intent-filter android:autoVerify="true" android:order="-1" android:priority="-1">
51+
^
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53+
54+
Here are the relevant source files:
55+
56+
`AndroidManifest.xml`:
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
58+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
59+
package="com.example.helloworld" >
60+
<uses-sdk android:minSdkVersion="31" android:targetSdkVersion="34" />
61+
62+
<application>
63+
<activity android:name=".SplitWebAndCustomActivity" android:exported="true">
64+
<intent-filter android:autoVerify="true" android:order="-1" android:priority="-1">
65+
<action android:name="android.intent.action.VIEW" />
66+
<category android:name="android.intent.category.DEFAULT" />
67+
<category android:name="android.intent.category.BROWSABLE" />
68+
<uri-relative-filter-group>
69+
<data android:path="/path" />
70+
<data android:query="queryparam=value" />
71+
</uri-relative-filter-group>
72+
<data android:scheme="http" />
73+
<data android:scheme="custom" />
74+
<data android:host="library.com" />
75+
<data android:path="@string/path" />
76+
<data android:path="/<&''" />
77+
<data android:path='/single"quote' />
78+
<data android:path="" />
79+
<!-- Test having tags underneath the host elements as well -->
80+
<action android:name="android.intent.action.SEND"/>
81+
<uri-relative-filter-group>
82+
<data android:path="/path" />
83+
<data android:query="queryparam=value" />
84+
</uri-relative-filter-group>
85+
</intent-filter>
86+
</activity>
87+
</application>
88+
</manifest>
89+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90+
91+
`res/values/strings.xml`:
92+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
93+
<resources>
94+
<string name="path">/path</string>
95+
</resources>
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+
<?xml version="1.0" encoding="UTF-8"?>
120+
<manifest xmlns:tools="http://schemas.android.com/tools">
121+
...
122+
<activity tools:ignore="AppLinkSplitToWebAndCustom" .../>
123+
...
124+
</manifest>
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+
<?xml version="1.0" encoding="UTF-8"?>
132+
<lint>
133+
<issue id="AppLinkSplitToWebAndCustom" severity="ignore" />
134+
</lint>
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+
<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

Lines changed: 225 additions & 0 deletions
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+
<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+
<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)