Status Update
Comments
be...@citymapper.com <be...@citymapper.com> #2
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
il...@google.com <il...@google.com> #3
Seems like this is already fixed in master as a side effect of
You'd want to add the snapshot repository to your repositories
block:
maven {
url "https://ci.android/com/builds/submitted/6080026/androidx_snapshot/latest/repository/"
}
then switch to androidx.fragment:fragment-ktx:1.3.0-SNAPSHOT
.
We'll look into cherry picking the changes into Fragment 1.2.0
be...@citymapper.com <be...@citymapper.com> #4
il...@google.com <il...@google.com> #5
Great, thanks for confirming.
While there isn't any specific changes needed for this issue (as the issue was already fixed before this bug was filed), I do want to explain what exactly is going to happen from a release process:
First, we'll be cherry picking in the changes needed into a Fragment 1.2.0-rc05 release (it was too late to hit rc04, which already went out earlier today). Namely, these two changes:
https://android-review.googlesource.com/1178750/ https://android-review.googlesource.com/1183079/ (this was the fix for the bug mentioned in , FWIW)comment#3
Secondly, we've added additional testing (in an unrelated, but fortuitously timed effort) specifically to cover this case to ensure this doesn't happen again in
mr...@gmail.com <mr...@gmail.com> #6
I'm curious why you need to limit the check to Build.VERSION.SDK_INT >= 17?
Description
Version used: 1.2.0-rc03
Devices/Android versions reproduced on:
- Pixel 3 API 27 Emulator
- Pixel 3 API 29 Emulator
- LG G7 ThinQ API 28
Sample code:
How to use:
- Make sure Fragment F1 is using layout fragment_f1_bad. Use the code to start the MainActivity, produce a configuration change (eg: rotate the device) --> it will crash due to an Exception is thrown in a check code.
- Changing F1 layout to fragment_f1_good and it will be fine.
Description:
- Saying I have a Fragment F1 in my Activity, defined either by xml (fragment tag or FragmentContainerView) or manual adding at runtime.
- F1's layout is defined in an xml with a 'fragment' tag whose name is a Fragment F2.
- The app starts normally as usual.
- If a configuration change happens, the destruction of F1 will call F2's onViewCreated.
In the sample app, I put a check code which checks if the Activity is destroyed or not, and in this case it will crash the app.
The expected behavior should be: the destruction of F1 should not call F2's onViewCreated.
This issue doesn't occur on 1.2.0-rc03 IF I use `FragmentContainerView` instead of `fragment` to add F2.
This issue cannot be reproduced on 1.2.0-rc02, 1.2.0-rc01 and (I believe) earlier versions.
Please find a call stack in attached screenshot (taken from a debug session on Pixel 3 API 29 Emulator).