Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle cannot find the com.huawei.agconnect plugin

Errorcom.huawei.agconnect plugin not found

Short answer

Gradle can only apply com.huawei.agconnect if it can download the AppGallery Connect plugin (agcp). That needs Huawei's Maven repository in the right place for your Android Gradle plugin version, plus the agcp classpath line in the root build file. Add both, sync, then apply the plugin in the app module.

  • Applies to Android Gradle Plugin 7.1 and later, Gradle 8.x, Android Studio current stable
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check which of the three pieces are present: the repository line, the agcp classpath, and the apply or plugins line.

    grep -rn -E "developer.huawei.com/repo|agcp|com.huawei.agconnect" --include=*.gradle --include=*.kts .
  2. 2Match what you see, then jump to its fix

    1. 1The grep finds no developer.huawei.com/repo lineHuawei's Maven repository is not declaredFix
    2. 2The repository is present, but no agcp line existsThe agcp classpath is missing from the root build fileFix
    3. 3No agconnect-services.json exists in the app folderagconnect-services.json is not in the app folderFix

What does the error look like?

  • com.huawei.agconnect plugin not found
  • Gradle sync fails on the apply plugin 'com.huawei.agconnect' line or the id in the plugins block

Cause 1 of 3

Huawei's Maven repository is not declared

1Check

The plugin is hosted in Huawei's repository. Newer projects declare repositories in settings.gradle; older ones in the root build.gradle.

grep -n -A6 -E "pluginManagement|dependencyResolutionManagement" settings.gradle

2Fix

For Android Gradle plugin 7.1 or later, add the line to both pluginManagement and dependencyResolutionManagement repositories in settings.gradle. For versions before 7.0, put it in buildscript and allprojects repositories in the root build.gradle.

// settings.gradle
pluginManagement {
    repositories {
        maven { url 'https://developer.huawei.com/repo/' }
    }
}
dependencyResolutionManagement {
    repositories {
        maven { url 'https://developer.huawei.com/repo/' }
    }
}

3Verify

Sync the project; the plugin line should stop reporting a missing plugin.

./gradlew help

Confirmed by developer.huawei.com

Did this fix it?

Cause 2 of 3

The agcp classpath is missing from the root build file

1Check

The root build.gradle must name the plugin artifact under buildscript dependencies. Use a version from Huawei's current release notes; 1.6.0.300 is the version shown in the guide.

grep -n "agcp" build.gradle

2Fix

Add the classpath line under buildscript, then apply the plugin in the app module.

// root build.gradle
buildscript {
    dependencies {
        classpath 'com.huawei.agconnect:agcp:1.6.0.300'
    }
}

// app/build.gradle
apply plugin: 'com.huawei.agconnect'

3Verify

Sync again and build the app module.

./gradlew :app:assembleDebug

Confirmed by developer.huawei.com

Did this fix it?

Cause 3 of 3

agconnect-services.json is not in the app folder

1Check

The guide says to add the agcp classpath once the configuration file is already in the app, and to download it from AppGallery Connect under Project settings, General information.

ls app/agconnect-services.json

2Fix

Download the file for this app and copy it into the app module's root directory.

cp ~/Downloads/agconnect-services.json app/

3Verify

Rebuild the module.

./gradlew :app:assembleDebug

Confirmed by developer.huawei.com

Did this fix it?

How do I stop it coming back?

  • Keep the Huawei repository line in settings.gradle together with the other repositories.
  • Open the Huawei Maven address only through the build, not the browser; the guide says it is not meant to be opened there.
  • Write in the README where agconnect-services.json must be placed, so a fresh clone builds.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.