joaomgcd / TaskerPluginSample

A library to help speed up building a Tasker plugin
GNU General Public License v3.0
62 stars 23 forks source link

Incompatibility with Android Gradle Plugin version 7.0 ? #7

Closed ribbons closed 3 years ago

ribbons commented 3 years ago

I've just started putting together a new Tasker plugin using the plugin library and referring to the samples in this repository (very useful, thanks!), and I'm seeing the following lint warning generated after adding the @field:TaskerInputField annotations to my input class.

"Resource IDs will be non-final in Android Gradle Plugin version 7.0, avoid using them as annotation attributes

Inspection info: Avoid the usage of resource IDs where constant expressions are required.

A future version of the Android Gradle Plugin will generate R classes with non-constant IDs in order to improve the performance of incremental compilation.

Issue id: NonConstantResourceId"

If I understand correctly, this means that the generated R.* classes won't contain static IDs any more as-of AGP v7 which will break passing the values to an annotation, so I'm not quite sure what the solution for the plugin library will be?

joaomgcd commented 3 years ago

Yeah, I saw that but haven't had time to change it yet. Although I did use it with v7 and didn't see an issue with it. What exactly is the problem with the IDs not being static? They won't be stored anywhere and are always looked up at runtime, so I'm not sure what could break with this change...

ribbons commented 3 years ago

My (quite limited!) understanding from a few searches on the topic was that as they were planning to switch the resource IDs to non-final they wouldn't then be able to be passed to an annotation because the value wouldn't be known at compile time.

However, yes - I'd agree that passing a resource ID to the annotation appears to compile just fine under the latest beta of the 7.0 plugin so I'm a bit confused really!

joaomgcd commented 3 years ago

The alternative I was thinking of was to specify the resources as strings ("R.string.something" instead of directly R.string.something) instead and then have the code look up the resource IDs at runtime. Wouldn't be as fast I know, but you probably wouldn't notice much.

But since it's still working I'm curious to know what the change will be exactly...

ribbons commented 3 years ago

But since it's still working I'm curious to know what the change will be exactly...

Yes, agreed!

Shall I leave this open until 7.0 of the AGP is released in case we see a change in behaviour or alternatively I'm happy to close it now if you'd prefer?

joaomgcd commented 3 years ago

Ok, let's close it now and re-open if needed :) Thanks!