It may require an import, but what do you think about explicitly checking for the Android library or project plugin?
```
if (it.plugins.hasPlugin("android")) {
 ...
}
```
or

```
import com.android.build.gradle.AppPlugin;

if (it.plugins.hasPlugin(AppPlugin)) {
 ...
}
```