Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Downgrade work-runtime to 2.6.0 if compileSdkVersion 30 or older is used #182

Merged
merged 5 commits into from
Nov 23, 2021

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Nov 22, 2021

Description

One Line Summary

Fixes tasks :app:checkDebugAarMetadata and checkReleaseAarMetadata failing at build time when a project has work-runtime:2.7.0 (OneSignal-Android-SDK 4.6.2 uses this) and compileSdkVersion 30 or older.

What is the build error output

Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > The minCompileSdk (31) specified in a
     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
     is greater than this module's compileSdkVersion (android-30).
     Dependency: androidx.work:work-runtime:2.7.0.
     AAR metadata file: /Users/myusername/.gradle/caches/transforms-3/ac32b6abd74d5ceefc471e061744b632/transformed/work-runtime-2.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.

Scope

Only affects app projects that contain work-runtime. Whether that is directly or indirectly through a dependency.

How was this implemented?

By checking for the app project's compileSdkVersion and defining a max version of 2.6.+ for work-runtime if compileSdkVersion is 30 or less.

Issues this fixes


This change is Reviewable

These two new tests fail on this commit and were added to show the issue
We will make them pass in the next commit in this PR.
Moving into helper method as we will utilize this in the next commit
Downgrade `work-runtime` to 2.6.0 if the app's `compileSdkVersion` is 30
or lower. This prevents build errors when AGP runs the task
`checkDebugAarMetadata`
This is required due the test
'Find min-support for Firebase and GMS - build' being fragile and
failing due to a new Google library being available.
Its pulling in `worker-runtime:2.7.0` from
`play-services-ads:+` -> `play-services-ads-lite:20.5.0`.
Set a version range for the `work-runtime` rule so it doesn't cause it
to be unintentionally upgraded. Added tests to ensure the senario is
covered.
Copy link

@nan-li nan-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat! Before, I didn't know what our Gradle plugin did.

Base automatically changed from fix/tests_for_new_onesignal_version_3.16.1 to main November 23, 2021 20:15
@jkasten2 jkasten2 merged commit 838734d into main Nov 23, 2021
@jkasten2 jkasten2 changed the title Downgrade work-runtime if needed Downgrade work-runtime to 2.6.0 if compileSdkVersion 30 or older is used Nov 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants