Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jh...@themeetgroup.com <jh...@themeetgroup.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/141 .
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1649748
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 79f71965d1d9180ce3c4a614e383a539a745d48d
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Thu Oct 17 13:16:26 2019
Add lint check for correct Fragment-Testing configuration
This lint check ensures that the fragment-testing library is included
using the debugImplementation configuration. The common way to include
this library is by using the androidTestImplementation configuration
which is incorrect.
Test: Added GradleConfigurationDetectorTest
Bug: 141500106
Change-Id: I6b4963890f5a40ca9b3b86af14d8f26e8cbc85ee
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/FragmentTestingIssueRegistry.kt
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/GradleConfigurationDetector.kt
A fragment/fragment-testing-lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/ApiLintVersionsTest.kt
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/GradleConfigurationDetectorTest.kt
https://android-review.googlesource.com/1145770
https://goto.google.com/android-sha1/79f71965d1d9180ce3c4a614e383a539a745d48d
Branch: androidx-master-dev
commit 79f71965d1d9180ce3c4a614e383a539a745d48d
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Thu Oct 17 13:16:26 2019
Add lint check for correct Fragment-Testing configuration
This lint check ensures that the fragment-testing library is included
using the debugImplementation configuration. The common way to include
this library is by using the androidTestImplementation configuration
which is incorrect.
Test: Added GradleConfigurationDetectorTest
Bug: 141500106
Change-Id: I6b4963890f5a40ca9b3b86af14d8f26e8cbc85ee
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/FragmentTestingIssueRegistry.kt
A fragment/fragment-testing-lint/src/main/java/androidx/fragment/testing/lint/GradleConfigurationDetector.kt
A fragment/fragment-testing-lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/ApiLintVersionsTest.kt
A fragment/fragment-testing-lint/src/test/java/androidx/fragment/testing/lint/GradleConfigurationDetectorTest.kt
fr...@google.com <fr...@google.com>
an...@google.com <an...@google.com> #4
sa...@peilicke.de <sa...@peilicke.de> #5
Using debugImplementation
breaks release unit tests. Normally, I wouldn't care but those are part of ./gradlew build
. Either change the lint check or provide another solution.
po...@gmail.com <po...@gmail.com> #6
Comment has been deleted.
Description
Version used: 1.1.0 (and most others)
Devices/Android versions reproduced on: N/A
The logical way that a developer would choose to add fragment-testing into the androidTest configuration is with:
androidTestImplementation "androidx.fragment:fragment-testing:1.1.0"
but this is invalid for Espresso Tests, because fragment-testing includes an EmptyFragmentActivity class that is used to bootstrap the FragmentScenario. That Activity must exist in the runtime application's Manifest, and it cannot be in the androidTest manifest because those activities can only start in the instrumentation process, not the application's process. Therefore the documentation <
debugImplementation "androidx.fragment:fragment-testing:1.1.0"
There is an open issue to improve the documentation to clarify why it needs to be debugImplementation and not androidTestImplementation, and to call it out as an explicit requirement (so it cannot be perceived to be an oversight). That issue is:
But to better catch this common error, it would great to have a Lint check that will fail if a project tries to include the fragment-testing artifact in the androidTest configuration, when it should instead be debugImplementation.