Gradle cannot find the com.huawei.agconnect plugin
com.huawei.agconnect plugin not foundShort 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.
Fix it fast
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 .2Match what you see, then jump to its fix
- 1
The grep finds no developer.huawei.com/repo lineHuawei's Maven repository is not declaredFix - 2
The repository is present, but no agcp line existsThe agcp classpath is missing from the root build fileFix - 3
No agconnect-services.json exists in the app folderagconnect-services.json is not in the app folderFix
- 1
What does the error look like?
com.huawei.agconnect plugin not foundGradle 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.gradle2Fix
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 helpConfirmed by developer.huawei.com
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.gradle2Fix
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:assembleDebugConfirmed by developer.huawei.com
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.json2Fix
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:assembleDebugConfirmed by developer.huawei.com
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
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile 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 fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile 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