Closed Bug 1544076 Opened 1 year ago Closed 11 months ago

Add lifecycle extensions library

Categories

(GeckoView :: General, enhancement, P2)

All
Android
enhancement

Tracking

(firefox66 wontfix, firefox67 wontfix, firefox68 fixed)

RESOLVED FIXED
mozilla68
Tracking Status
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- fixed

People

(Reporter: esawin, Assigned: esawin)

References

(Blocks 3 open bugs)

Details

(Whiteboard: [gvtv:p1])

Attachments

(3 files, 2 obsolete files)

There are situations where GeckoRuntime should take action depending on the lifecycle of the app process, e.g., when the app moves to background or is resumed back to foreground, see bug 1536797 for example.

We should make GeckoRuntime lifecycle-aware.

Blocks: 1536797
Assignee: nobody → esawin
Type: defect → enhancement

Nick, I'm trying to add the "android.arch.lifecycle:extensions:1.1.1" dependency for ProcessLifecycleOwner etc., see https://phabricator.services.mozilla.com/D27360.

It builds when using api, but fails when using implementation with an error (Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.1) classpath. You should manually set the same version via DependencyResolution).

I've tried to manually resolve the dependency, but to no avail. Can you give me a hint on how to resolve this?

Flags: needinfo?(nalexander)

(In reply to Eugen Sawin [:esawin] from comment #2)

Nick, I'm trying to add the "android.arch.lifecycle:extensions:1.1.1" dependency for ProcessLifecycleOwner etc., see https://phabricator.services.mozilla.com/D27360.

It builds when using api, but fails when using implementation with an error (Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.1) classpath. You should manually set the same version via DependencyResolution).

This means that there are two versions of this dependency at play. That could mean there's an existing dependency, or that you're adding two dependencies in your commits. The latter is unlikely, so I started by checking if we already have such a dependency.

I've tried to manually resolve the dependency, but to no avail. Can you give me a hint on how to resolve this?

Sure. To check if we already have such a dependency, I used

./mach gradle -- geckoview:androidDependencies

which shows many blocks like

> Task :geckoview:androidDependencies
withGeckoBinariesDebug
withGeckoBinariesDebugCompileClasspath - Dependencies for compilation
+--- com.android.support:support-v4:26.1.0@aar
+--- com.android.support:palette-v7:26.1.0@aar
+--- com.android.support:support-media-compat:26.1.0@aar
+--- com.android.support:support-fragment:26.1.0@aar
+--- com.android.support:support-core-utils:26.1.0@aar
+--- com.android.support:support-core-ui:26.1.0@aar
+--- com.android.support:support-compat:26.1.0@aar
+--- com.android.support:support-annotations:26.1.0@jar
+--- android.arch.lifecycle:runtime:1.0.0@aar
+--- android.arch.lifecycle:common:1.0.0@jar
\--- android.arch.core:common:1.0.0@jar

So yes, we definitely already have this lifecycle dependency. Now, where is it coming from? I picked an arbitrary Gradle configuration, like the one above, and ran:

./mach gradle -- geckoview:dependencies --configuration withGeckoBinariesDebugCompileClasspath

and I see

withGeckoBinariesDebugCompileClasspath - Resolved configuration for compilation for variant: withGeckoBinariesDebug
+--- com.android.support:support-v4:26.1.0
|    +--- com.android.support:support-compat:26.1.0
|    |    +--- com.android.support:support-annotations:26.1.0
|    |    \--- android.arch.lifecycle:runtime:1.0.0
|    |         +--- android.arch.lifecycle:common:1.0.0
|    |         \--- android.arch.core:common:1.0.0
...

That tells me that support-compat:26.1.0 expects android.arch.lifecycle:common:1.0.0 at this time. Another way to do this is to use Gradle dependencyInsight, like

./mach gradle -- -q geckoview:dependencyInsight --dependency 'android.arch.lifecycle:common' --configuration withGeckoBinariesDebugCompileClasspath
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=utf-8
android.arch.lifecycle:common:1.0.0
   variant "runtime" [
      org.gradle.status                                            = release (not requested)
      Requested attributes not found in the selected variant:
         com.android.build.api.attributes.BuildTypeAttr               = debug
         geckoBinaries                                                = withGeckoBinaries
         org.gradle.usage                                             = java-api
         com.android.build.gradle.internal.dependency.AndroidTypeAttr = Aar
   ]

android.arch.lifecycle:common:1.0.0
\--- android.arch.lifecycle:runtime:1.0.0
     \--- com.android.support:support-compat:26.1.0
          +--- com.android.support:support-v4:26.1.0
          |    \--- withGeckoBinariesDebugCompileClasspath
          +--- com.android.support:palette-v7:26.1.0
          |    \--- withGeckoBinariesDebugCompileClasspath
          +--- com.android.support:support-media-compat:26.1.0
          |    \--- com.android.support:support-v4:26.1.0 (*)
          +--- com.android.support:support-fragment:26.1.0
          |    \--- com.android.support:support-v4:26.1.0 (*)
          +--- com.android.support:support-core-utils:26.1.0
          |    +--- com.android.support:support-v4:26.1.0 (*)
          |    +--- com.android.support:palette-v7:26.1.0 (*)
          |    \--- com.android.support:support-fragment:26.1.0 (*)
          \--- com.android.support:support-core-ui:26.1.0
               +--- com.android.support:support-v4:26.1.0 (*)
               \--- com.android.support:support-fragment:26.1.0 (*)

Basically the same information, but more focused.

Now we go poke at the support-compat library and try to understand its dependencies. A little bit of Googling finds this list of relevant versions and a little manual curling shows that 27.1.1 depends on 1.1.0:

    <dependency>
      <groupId>android.arch.lifecycle</groupId>
      <artifactId>runtime</artifactId>
      <version>1.1.0</version>
      <type>aar</type>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <artifactId>support-annotations</artifactId>
          <groupId>*</groupId>
        </exclusion>
      </exclusions>
    </dependency>

and that 28.0.0 depends on 1.1.1:

    <dependency>
      <groupId>android.arch.lifecycle</groupId>
      <artifactId>runtime</artifactId>
      <version>1.1.1</version>
      <type>aar</type>
      <scope>compile</scope>
    </dependency>

You can keep narrowing down to figure out exactly when the versions bump. So my suggestion is that you pursue upgrading the support libraries such that they match the new things you want to consume, rather than "switch out" dependency versions with substitutions.

Flags: needinfo?(nalexander)
Blocks: 1545266
Priority: -- → P2
Whiteboard: [gvtv:p1]

Depends on D27971

Depends on D28082

Attachment #9057976 - Attachment is obsolete: true
Summary: Make GeckoRuntime lifecycle-aware → Add lifecycle extensions library
Attachment #9059096 - Attachment description: Bug 1544076 - [0.0] Upgrade Android support library to 28.0.0 to avoid version conflicts with the lifecycle library. → Bug 1544076 - [0.1] Upgrade Android support library to 28.0.0 to avoid version conflicts with the lifecycle library.
Pushed by esawin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cda2f454e6ed
[0.1] Upgrade Android support library to 28.0.0 to avoid version conflicts with the lifecycle library. r=nalexander,droeh
https://hg.mozilla.org/integration/autoland/rev/45730400480e
[1.1] Add lifecycle library dependency. r=nalexander,snorp
Attachment #9059314 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.