I am writing a library for an Android application to support Huawei push notifications on Android. According to Huawei documentation, I have to apply a plugin to the application module. But I want to make my library to do it for the user of the library.
I have read the topic in which they say, that I must use fully classified classname to add the plugin to the project. So I used the command ./gradlew tasks
to see the fully classified classname for plugin com.huawei.agconnect
and it is com.huawei.agconnect.agcp.AGCPlugin
.
The code I use in my library module build.gradle :
evaluationDependsOn(':app')
rootProject.subprojects {
if (name == "app") {
if (!plugins.hasPlugin('com.huawei.agconnect')) {
apply {
plugin com.huawei.agconnect.agcp.AGCPlugin
}}}}
The problem is the way I apply Huawei plugin from my library module build.gradle file doesn’t work correctly. When I use apply plugin: 'com.huawei.agconnect'
in app module everything works perfectly.
Have I missed anything? What is the difference between ‘apply plugin’ in main module and the way I am applying the plugin from my library module? Help me please to figure it out.