Skip to content

Android manifest activities reset to .MainActivity when configuring package #233

@hcentelles

Description

@hcentelles

Summary

Running @trapezedev/configure on an Android project resets every <activity>’s android:name attribute in AndroidManifest.xml to .MainActivity. The transform is only supposed to touch the app’s launcher activity.

Steps to reproduce

  1. In config.yaml, set platforms.android.packageName (or leave the default staging value).
  2. Ensure the project has additional activities (e.g., Facebook’s com.facebook.FacebookActivity and com.facebook.CustomTabActivity).
  3. Run npx @trapezedev/configure <config> android.
  4. Open android/app/src/main/AndroidManifest.xml.

Expected behavior

Only the main launcher activity should have its package updated.

Actual behavior

All <activity> nodes get rewritten to android:name=".MainActivity", breaking third-party activities.

Root cause

AndroidProject.setPackageName() calls:

this.manifest.setAttrs('manifest/application/activity', {
    'android:name': activityName
});

setAttrs updates every matching node. When the manifest lacks a <manifest package="…"> attribute (common with AGP 8+), activityName stays .MainActivity, so the loop overwrites each activity.

Environment

  • @trapezedev/configure 7.1.3
  • Capacitor/Cordova Android project (AGP 8+ manifest without a manifest@package attribute)

Suggested fix

Update setPackageName() to target only the main/launcher activity—e.g., select the one with android.intent.action.MAIN or android:name='.MainActivity'—instead of every <activity>.

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