isandoqa
isandoqa

Reputation: 13

Unable to configure huawei agconnect in my android project

I have an android application where I am trying to configure the HMS SDK, I followed the document to created an app in the app gallery, download the config json file, but when trying to add the agconnect plugin I faced some issues, first that I am using gradle DSL, while the document is written for older gradle. I followed the answer here:

https://stackoverflow.com/questions/71121109/com-huawei-agconnect-plugin-not-found#:~:text=Any%20Gradle%20plugin%20(this%20is%20not%20AGC%20specific%20at%20all)%20can%20only%20be%20loaded%20at%20the%20root%20project%20level%2C%20and%20then%20usually%20be%20applied%20on%20the%20module%20level.%20I%27ve%20just%20tried%20to%20remove%20the%20buildscript%20block%20(alike%20in%20the%20question)%2C%20which%20indeed%20leads%20to%3A

to be able to download the plugin.

Now I am facing the following build error that I cannot pass yet,

An exception occurred applying plugin request [id: 'com.huawei.agconnect', artifact: 'com.huawei.agconnect:agcp:1.9.1.301']
> Failed to apply plugin 'com.huawei.agconnect'.
   > com.android.tools.build:gradle is no set in the build.gradle file

Here is my project level build.gradle file:

plugins {
    id 'com.android.application' version '7.4.2' apply false
    id 'com.android.library' version '7.4.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
    id 'com.google.gms.google-services' version '4.3.15' apply false
    id 'com.huawei.agconnect' version '1.9.1.301' apply false
}

and here is my settings.gradle file:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
        maven { url "https://jitpack.io" }
        maven {url "https://developer.huawei.com/repo/"}
        jcenter()
    }
    resolutionStrategy {
        eachPlugin {
            println ">> ${it.requested.id.id}"
            println ">> ${it.requested.id.namespace}"
            println("-------------------------")
            if (it.requested.id.id == 'com.huawei.agconnect') {
                it.useModule('com.huawei.agconnect:agcp:1.9.1.301')
            }
        }
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven {url "https://developer.huawei.com/repo/"}
    }
}
rootProject.name = "NotificationSample"
include ':app'
include ':NotifySDK'

and here is the plugins part from app module build.gradle file

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
    id 'com.huawei.agconnect'
}

which is not build. Any ideas about how to solve this?

Upvotes: 1

Views: 260

Answers (0)

Related Questions