trapeze icon indicating copy to clipboard operation
trapeze copied to clipboard

Android manifest activities reset to .MainActivity when configuring package

Open hcentelles opened this issue 2 months ago • 0 comments

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>.

hcentelles avatar Nov 05 '25 19:11 hcentelles