Skip to content

AGP 8+ build failure: missing mandatory namespace in Huawei Flutter plugins #439

@juandpt03

Description

@juandpt03

Environment
Flutter 3.38.9 • channel stable
Android Gradle Plugin: 8.9.1
Kotlin: 2.1.0

huawei_hmsavailability: 6.12.0+300
huawei_iap: 6.13.0+305

Affected plugins

huawei_hmsavailability 6.12.0+300

huawei_iap 6.13.0+305

Problem

Starting with Android Gradle Plugin 8.0, the namespace property is mandatory for all Android library modules.
The package attribute in AndroidManifest.xml is no longer used for this purpose.

Both plugins currently do not declare a namespace, which causes the same build failure under AGP 8+.

Build error
Namespace not specified. Specify a namespace in the module's build file.

Details
huawei_hmsavailability (6.12.0+300)
android {
compileSdkVersion 33
buildToolsVersion "31.0.0"

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 33
}

}

huawei_iap (6.13.0+305)
android {
compileSdkVersion 34
buildToolsVersion "31.0.0"

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 34
}

}

Expected behavior

Plugins should build successfully on:

Legacy AGP (< 7.x)

Modern AGP (8+)

Suggested fix (legacy-compatible)

Declare namespace only when supported, using a guarded check.
This keeps compatibility with older Android Gradle Plugin versions while fixing AGP 8+.

huawei_hmsavailability
android {
compileSdkVersion 33

if (project.android.hasProperty("namespace")) {
    namespace "com.huawei.hms.flutter.hmsavailability"
}

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 33
}

}

huawei_iap
android {
compileSdkVersion 34

if (project.android.hasProperty("namespace")) {
    namespace "com.huawei.hms.flutter.iap"
}

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 34
}

}

Notes:
namespace is supported since AGP 4.2
Mandatory starting from AGP 8.0
Guarded declaration avoids breaking older build setups
Same fix applies consistently to both plugins

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions