Skip to content

Plugin's default application of Work api causes crash on Android 12 #349

@RBusarow

Description

@RBusarow

If the plugin is applied to any module in a project, and workEnabled isn't explicitly set to false, and the project in question isn't using Androidx work 2.7.0, then there'll be a crash if the project is run on an Android 12 device:

 java.lang.IllegalArgumentException: ***********: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

The plugin adds implementation dependencies for Tangle artifacts for Fragment, ViewModel, and Work(Manager) API's by default.

This leaks the transitive dependencies of the corresponding Androidx libraries. If the project is using the Androidx libraries, then Gradle's dependency resolution should take care of any conflicts. But if the project doesn't supply its own version, Tangle's leaked dependencies will make it to the APK (at least in non-minified builds).

There are two options I can think of:

  1. Just disable Work by default, since it's probably not all that common anyway. I don't love this approach.
  2. Use a Gradle API like afterEvaluate { ... } or tasks.withType<KotlinComplile> { ... } to inspect the target project's dependencies and determine which Tangle features to enable at that time. For instance, if the target has AAC Work as a dependency, Tangle will automatically add its own Work dependency and compiler extension. In this case, the TangleExtension feature-toggle properties should be nullable. If they're un-set (null), then configuration is done via this inspection. If the property is explicitly set to true or false, then that setting is used instead and the inspection is skipped.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions