Skip to content

[Bug] Android Gradle Plugin 8.x compatibility - package attribute in AndroidManifest.xml causes build failure #178

@omaralqaseer

Description

@omaralqaseer

Bug Description

When using Android Gradle Plugin 8.0 or higher, the build fails due to the deprecated package attribute in the AndroidManifest.xml file.

Error Message

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':freerasp:processReleaseManifest'.
    A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
    Incorrect package="com.aheaditec.freerasp" found in source AndroidManifest.xml: /Users/[user]/.pub-cache/hosted/pub.dev/freerasp-[version]/android/src/main/AndroidManifest.xml.
    Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
    Recommendation: remove package="com.aheaditec.freerasp" from the source AndroidManifest.xml

Environment

  • Android Gradle Plugin: 8.0+
  • Platform: Android
  • Flutter: Any version using modern AGP

Root Cause

Android Gradle Plugin 8.0+ no longer supports the package attribute in AndroidManifest.xml. The namespace should be declared in the module's build.gradle file instead.

Current Problematic Code

File: android/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.aheaditec.freerasp">
</manifest>

Proposed Solution

1. Remove the package attribute from AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

2. Update build.gradle to use unconditional namespace:
android {
    namespace "com.aheaditec.freerasp"
    // ... rest of config
}

Impact

This issue affects all Flutter projects using Android Gradle Plugin 8.0+ with freerasp, forcing developers to downgrade their build tools.

Current Workaround

Developers must downgrade to AGP 7.x, which prevents using modern Android development features and tooling.

References

- https://developer.android.com/studio/build/configure-app-module#set-namespace
- https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes

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