spotify / ruler

Gradle plugin which helps you analyze the size of your Android apps.
Apache License 2.0
1.13k stars 58 forks source link

Fixed `AGP 8.3.0` breaking change #154

Closed gmazzo closed 7 months ago

gmazzo commented 7 months ago

What has changed

Addresses #153 with a minimal set of changes to unblock the consumers of this plugin.

The breaking change is produced because the plugin is accessing an internal AGP API for getting the Android SDK location.

As suggested by @SimonMarquis, this can be done with a public API in BaseExtension.sdkDirectory. I made minimal changes to read from there, falling back to an ANDROID_HOME environment variable if not provided to keep the coupling at the bare minimum.

Additionally, I've moved the whole ANDROID_GRADLE_PLUGIN dependency as a compileOnly to avoid leaking it to the consumers

Why was it changed

Because since AGP 8.3.0, the internal API signature has changed, and it breaks: #153

Related issues

AGP 8.3.0 fails with NoSuchMethodError #153

[!NOTE] This project is a bit outdated on its dependencies: A bump to 8.3.0 was not possible without also bumping Gradle to at least 8.4, and doing so introduced a new problem with accessing a removed API

> An exception occurred applying plugin request [id: 'com.guardsquare.proguard']
> Failed to apply plugin 'com.guardsquare.proguard'.
   > API 'android.registerTransform' is removed.
nathan3d commented 7 months ago

Can you update the Gradle version(s) in checks matrix so the tests can pass?

gmazzo commented 7 months ago

Can you update the Gradle version(s) in the checks matrix so the tests can pass?

Can you provide better actionable feedback? Which versions of Gradle should we be targeting?

I've checked locally, and main seems to be currently broken. Running ./gradlew check -s from a fresh checkout prints:

java.lang.StackOverflowError
        at java.base/java.util.TreeSet.iterator(TreeSet.java:181)
        at org.gradle.execution.plan.FinalizerGroup.isCanCancel(FinalizerGroup.java:153)
        at org.gradle.execution.plan.CompositeNodeGroup.isCanCancel(CompositeNodeGroup.java:101)
        at org.gradle.execution.plan.Node.isCanCancel(Node.java:232)
        at org.gradle.execution.plan.FinalizerGroup.isCanCancel(FinalizerGroup.java:155)
        at org.gradle.execution.plan.CompositeNodeGroup.isCanCancel(CompositeNodeGroup.java:101)
        at org.gradle.execution.plan.Node.isCanCancel(Node.java:232)

It seems my changes didn't introduce this issue, but rather this project needs more active contributions. Is it even maintained?

Fixing the whole build should be addressed in a separate PR, not in this one.

nathan3d commented 7 months ago

Can you update the Gradle version(s) in the checks matrix so the tests can pass?

Can you provide better actionable feedback? Which versions of Gradle should we be targeting?

I've checked locally, and main seems to be currently broken. Running ./gradlew check -s from a fresh checkout prints:

java.lang.StackOverflowError
        at java.base/java.util.TreeSet.iterator(TreeSet.java:181)
        at org.gradle.execution.plan.FinalizerGroup.isCanCancel(FinalizerGroup.java:153)
        at org.gradle.execution.plan.CompositeNodeGroup.isCanCancel(CompositeNodeGroup.java:101)
        at org.gradle.execution.plan.Node.isCanCancel(Node.java:232)
        at org.gradle.execution.plan.FinalizerGroup.isCanCancel(FinalizerGroup.java:155)
        at org.gradle.execution.plan.CompositeNodeGroup.isCanCancel(CompositeNodeGroup.java:101)
        at org.gradle.execution.plan.Node.isCanCancel(Node.java:232)

It seems my changes didn't introduce this issue, but rather this project needs more active contributions. Is it even maintained?

Fixing the whole build should be addressed in a separate PR, not in this one.

I thought it was broken with your update, but seems to just be broken in general. I'll see if I can get it fixed.

gmazzo commented 7 months ago

I thought it was broken with your update, but seems to just be broken in general. I'll see if I can get it fixed.

Actually, I have it fixed locally already.

The main offender is the com.guardsquare.proguard plugin, which it seems discontinued (up to AGP 7.x) and redundant, as AGP always had it embedded and later replaced with R8.

After removing it, and therefore the sample/proguard project I was able to fix the build, and even bump both Gradle and AGP versions to the latest.

I just submitted #158 fixing the build

gmazzo commented 7 months ago

Closing in favor of #159