-
Notifications
You must be signed in to change notification settings - Fork 6k
Make FlutterFragment usable without requiring it to be attached to an Android Activity. #27332
Make FlutterFragment usable without requiring it to be attached to an Android Activity. #27332
Conversation
Android Activity. - call getContext instead of getActivity in FlutterActivityAndFragmentDelegate.onCreateView
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add a test to verify that onCreateView doesn't call getActivity, but instead getContext?
Yes I was looking into this but I can't seem to get the tests to run locally. Are there any docs to help with that? Currently I'm getting: When I try to run |
|
what about |
|
actually, I'm seeing the same issue. cc @dnfield Is this related to recent changes? |
|
Make sure you build the target(s) first - run_tests.py used to do some of that for you but doesn't anymore because it messed up things on LUCI. /cc @zanderso fyi |
|
Do you mean just run |
|
Make sure to also build the Since the test script doesn't build that target for you anymore, we should really add it to the default Android build rule, at least for the case of armv7 debug. |
|
The build ran correctly (I think). But I'm still the same java.lang.IllegalArgumentException when I try to run the test. |
|
That error sounds like there's something missing in the way the test is set up or decorated. |
|
It's not a test I added fwiw. Are you saying it's broken at head? Are unit test not run by your presubmit? What should I do? |
|
I am able to run these tests at head :/. They run on the Linux android debug shard |
|
Oh hmm. I'm trying to run on mac. I suppose I could try and run it on linux. Do you think that will help? |
|
I ran it locally on mac. |
|
Hmm. I think some sort of instructions for setup would be helpful. |
|
This works for me from the |
|
The only thing I can think of - this is all using JDK 1.8. For better or worse we use your system JDK and do not vend a JDK with the engine repo. I think JDK 1.9 should work, but I'm willing to bet JDK 1.10/11/12 will not. |
|
So for me, |
|
ok I changed the java version and that finally worked! Thanks. I'll send over the unit tests soon. |
|
For reference I ran this from the src dir: |
|
And I had to install Java 8 by downloading it from the oracle website and manually editing my PATH. |
|
Ok. I made sure there's test coverage. I opted to modify an existing test instead of adding a new one since that seemed appropriate in this case. Should I add/modify docs somewhere so people know FlutterFragment can be used without an Activity? Or is too niche a use case? |
dnfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
If you want to update docs that's fine, but AFAIK this use case was always intended to be supported and this code just slipped through the cracks.
|
Waiting to apply the label on review from @blasten |
blasten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ed to an Android Activity. (flutter/engine#27332)
…e attached to an Android Activity. (flutter#27332)" (flutter#27382)" This reverts commit 093c4ed.
… Android Activity. (flutter#27332)
…ed to an Android Activity. (flutter#27332)" (flutter#27382) This reverts commit 317166d.
… Android Activity. (flutter#27332)
…ed to an Android Activity. (flutter#27332)" (flutter#27382) This reverts commit 317166d.
Fixes: flutter/flutter#85326
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.