Closed Bug 1320310 Opened 8 years ago Closed 7 years ago

Local builds: Home screen icon disappears when switching between gradle/mach build

Categories

(Firefox Build System :: Android Studio and Gradle Integration, defect)

All
Android
defect
Not set
normal

Tracking

(firefox55 fixed)

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: sebastian, Assigned: nalexander)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Whenever I build with mach/gradle, install the app, add a home screen icon and then switch to the other build mechanism (mach -> gradle, gradle -> mach) then the home screen icon disappears on install.

For local builds this is not really an issue, but it's an indicator that the manifest entries might be slightly different and then this could be an issue if  we switch release builds to gradle - e.g. see bug 1268455, bug 1256615.
Diff of AndroidManifest.xml between mach and Gradle build.

There are two diffs, first is the component name from activity-alias is not full class name but short class name starts with a dot(.App). Gradle build appends the prefix "org.mozilla.gecko" from the package of the manifest which mach build don't. This is the root cause of this bug because the component name are different in Launcher app design.

I think explicit specify the full class name is more consistent and better comparing to current dot prefix behavior. But on the other hand, one-time shortcut missing on home screen is still an impact to current user.

@Sebastian: What do you think?
Flags: needinfo?(s.kaspari)
> I think explicit specify the full class name is more consistent and better comparing to current
> dot prefix behavior. But on the other hand, one-time shortcut missing on home screen is still an
> impact to current user.

Yeah, it would be nicer to use the full class name. However we can't purge launcher icons from all our users. And we have partnerships where partners add Firefox to the home screen - it would be counter productive to remove them again with an update. :)

I wonder if we can find a workaround so that this doesn't happen when building with gradle?

And we should file another bug for the AppMeasurement things. Even if we can't prevent them from getting into the manifest we at least want to disable the reporting (afaik you can do that with a specific meta-data tag in the manifest).
Flags: needinfo?(s.kaspari)
(In reply to Sebastian Kaspari (:sebastian) from comment #2)
> > I think explicit specify the full class name is more consistent and better comparing to current
> > dot prefix behavior. But on the other hand, one-time shortcut missing on home screen is still an
> > impact to current user.
> 
> Yeah, it would be nicer to use the full class name. However we can't purge
> launcher icons from all our users. And we have partnerships where partners
> add Firefox to the home screen - it would be counter productive to remove
> them again with an update. :)

Sadly, this is one of these things that I think the launcher(s) get wrong and we will have to support essentially forever.

> I wonder if we can find a workaround so that this doesn't happen when
> building with gradle?

It's not easy, but we can probably find a way to achieve this in Gradle.  Two thoughts:
- does inserting a dummy empty variable prevent Gradle doing the expansion?  Like "${dummyPlaceholder}.App".
- it is possible, but not easy, to post-process the various .xml files produced.  I've tried and failed to do this for certain things in the past.

> And we should file another bug for the AppMeasurement things. Even if we
> can't prevent them from getting into the manifest we at least want to
> disable the reporting (afaik you can do that with a specific meta-data tag
> in the manifest).

I concur.
https://android.googlesource.com/platform/tools/base/+/master/sdk-common/src/main/java/com/android/ide/common/xml/AndroidManifestParser.java#393

I also found there is no way to skip the prepend process. Looks like the post processing is the only workaround.

Nice hack! Thanks Nick.
Comment on attachment 8857313 [details]
Bug 1320310 - Post-process Gradle-produced Android manifest.

https://reviewboard.mozilla.org/r/129278/#review131902

Nice :)
Attachment #8857313 - Flags: review?(s.kaspari) → review+
Pushed by nalexander@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/364265dfdf2c
Post-process Gradle-produced Android manifest. r=sebastian
Assignee: nobody → nalexander
Status: NEW → ASSIGNED
Pushed by nalexander@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c85665cc6260
Post-process Gradle-produced Android manifest. r=sebastian
https://hg.mozilla.org/mozilla-central/rev/c85665cc6260
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Clearing NI, since I fixed and landed this.
Flags: needinfo?(nalexander)
maliu: would you mind testing this?
Flags: needinfo?(max)
(In reply to Nick Alexander :nalexander from comment #13)
> maliu: would you mind testing this?

Verify fixed; both of the AndroidManifest.xml are identical.

However sadly, there is a regression while integrating with android-studio. We can no longer launch activity from android-studio because the component it tried to launch is the one with prefix, not the modified one. Even when I try to specify manually, still fail because android-studio thinks the component does not exist.

```
$ adb shell am start -n "org.mozilla.fennec_maliu/org.mozilla.gecko.App" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "org.mozilla.fennec_maliu/org.mozilla.gecko.App" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.mozilla.fennec_maliu/org.mozilla.gecko.App }
Error type 3
Error: Activity class {org.mozilla.fennec_maliu/org.mozilla.gecko.App} does not exist.

Error while Launching activity
```

This regression with android-studio also blocks us using instant-run. T_T

@Nick
Consider sending a patch to android-studio? ;)
Flags: needinfo?(max) → needinfo?(nalexander)
Huh, that's interesting.  I wonder what would happen if we added a second alias for .App as well?  I'll have to think that through.
Flags: needinfo?(nalexander)
Nick, I just remembered the bouncer and was wondering whether we need to apply the same post-processing there?
Flags: needinfo?(nalexander)
(In reply to Sebastian Kaspari (:sebastian) from comment #16)
> Nick, I just remembered the bouncer and was wondering whether we need to
> apply the same post-processing there?

Yeah, I guess we should.  I kind of want to get rid of the bouncer entirely, but until we do that, you're right -- we should ensure that the Gradle bouncer and app APKs agree.  I'll file.
Flags: needinfo?(nalexander)
Blocks: 1360587
Blocks: 1363526
No longer blocks: gradle-automation
Product: Firefox for Android → Firefox Build System
Target Milestone: Firefox 55 → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: