Skip to content

AndroidManifest.xml package attribute error with AGP 8.x and newer build tools #10755

Open
@guilpablo

Description

@guilpablo

Issue Description

Environment

  • NativeScript CLI: 8.6.5
  • @nativescript/core: 8.9.2
  • @nativescript/android: 8.9.1
  • Android SDK: 30 (also tested with 34)
  • Build Tools: 30.0.3 (also tested with 34.0.0)
  • AGP: 7.0.4 (forced via before-plugins.gradle)
  • OS: macOS 14.3.0

Issue Description

The NativeScript core plugin generates AndroidManifest.xml with package="org.nativescript.core" attribute in the <manifest> tag, which is no longer supported by newer Android Gradle Plugin versions (AGP 7.2+).

Error Message

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':processReleaseManifest'.

A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
Incorrect package="org.nativescript.core" found in source AndroidManifest.xml: /path/to/platforms/tempPlugin/core/src/main/AndroidManifest.xml.
Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
Recommendation: remove package="org.nativescript.core" from the source AndroidManifest.xml

Reproduction

## Steps to Reproduce
1. Create a new NativeScript project or use existing one
2. Run `ns build android`
3. Error occurs during plugin build phase

## Attempted Solutions (All Failed)
1. **Manual patching:** Created scripts to remove `package` attribute after prepare/build
2. **CLI hooks:** Tried `after-prepare` and `before-build` hooks
3. **Gradle patching:** Attempted to patch manifest during build process
4. **Upgrading:** Updated to latest NativeScript versions (8.9.x)
5. **Downgrading:** Downgraded to SDK 30, build tools 30.0.3, AGP 7.0.4
6. **Postinstall scripts:** Automated patching after npm install

### Relevant log output (if applicable)

## Root Cause Analysis
The issue is that the NativeScript core plugin generates the manifest dynamically during build, and there is no static source file in `node_modules` to patch. The manifest is regenerated after every prepare/build, making all local workarounds ineffective.

## Expected Behavior
The NativeScript core plugin should generate `AndroidManifest.xml` without the `package` attribute, or use the `namespace` attribute instead, to be compatible with newer AGP versions.

## Impact
This prevents building NativeScript projects with newer Android build tools, forcing developers to use outdated tooling or abandon NativeScript for Android development.

## Additional Notes
- The manifest is generated at: `platforms/tempPlugin/core/src/main/AndroidManifest.xml`
- No static source file exists in `node_modules/@nativescript/core/platforms/android/`
- This affects all NativeScript 8.x projects using newer Android build tools

Environment

No response

Please accept these terms

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-pending-triageReported bug, pending triage to confirm.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions