Skip to content

fix(expo-plugin): move android_initialisation_config.xml to res/xml/#97

Open
abh1abii wants to merge 1 commit intomoengage:masterfrom
abh1abii:fix/android-initialisation-config-xml-path
Open

fix(expo-plugin): move android_initialisation_config.xml to res/xml/#97
abh1abii wants to merge 1 commit intomoengage:masterfrom
abh1abii:fix/android-initialisation-config-xml-path

Conversation

@abh1abii
Copy link
Copy Markdown

@abh1abii abh1abii commented Mar 4, 2026

Summary

The Expo config plugin incorrectly copies android_initialisation_config.xml
into android/app/src/main/res/values/. This causes a hard build failure during
the packageDebugResources / packageReleaseResources Gradle task for all users
of the Expo managed workflow.

Error produced:

ERROR: .../res/values/android_initialisation_config.xml:
Resource and asset merger: Can't determine type for tag
'YOUR_APP_ID'

Affected file:
src/android/constants.ts (line 48) → compiled to build/android/constants.js (line 44)


Root Cause

The Android resource merger enforces strict rules on the contents of res/values/.
Every XML file placed there must have <resources> as its root element, and
every child element must be a recognised Android resource type (<string>,
<color>, <dimen>, etc.).

android_initialisation_config.xml uses <MoEngageConfiguration> as its root,
which the resource merger cannot type-check — hence the Can't determine type for tag error.

From the official Android documentation on
res/values/:

XML files containing simple values, such as strings, integers, and colors.
Whereas other res/ subdirectories define a single resource per file, files
in res/values/ describe multiple resources. The root element of these files
must be a <resources> element.

The correct directory is res/xml/, which is explicitly designed for
arbitrary XML files read at runtime:

From the official Android documentation on
res/xml/:

Arbitrary XML files that can be read at runtime by calling
Resources.getXML(). Various XML configuration files must be saved here.

The MoEngage Android SDK reads android_initialisation_config.xml via its own
XML parser — not through Android's <resources> system — making res/xml/ the
semantically and technically correct location.


Change

src/android/constants.ts:

-export const xmlValuesResourcePath = './android/app/src/main/res/values';
+export const xmlValuesResourcePath = './android/app/src/main/res/xml';

The res/xml/ directory is already present in Expo-managed Android projects
(Expo itself places locales_config.xml there), so no directory creation is
needed.


Steps to Reproduce

  1. Create a new Expo managed project with react-native-expo-moengage configured
    in app.json plugins.
  2. Run npx expo prebuild --platform android.
  3. Run npx expo run:android or ./gradlew app:assembleDebug.

Result: Build fails with:
Task :app:packageDebugResources FAILED
ERROR: .../res/values/android_initialisation_config.xml:
Resource and asset merger: Can't determine type for tag 'YOUR_APP_ID'

Expected: Build succeeds; android_initialisation_config.xml is placed in
res/xml/ where the resource merger does not attempt to type-check its elements.


Testing

After applying this patch:

  1. Run npx expo prebuild --platform android --clean.
  2. Verify android/app/src/main/res/xml/android_initialisation_config.xml exists.
  3. Verify android/app/src/main/res/values/android_initialisation_config.xml does not exist.
  4. Run npx expo run:android — build should succeed.
  5. Confirm MoEngage push notifications and analytics initialise correctly at runtime.

References

Files in res/values/ must have <resources> as their root element.
android_initialisation_config.xml uses <MoEngageConfiguration> as its
root, causing the Android resource merger to fail with:

  Can't determine type for tag '<appId>...'

The correct destination is res/xml/, which is designed for arbitrary
XML files read at runtime and is not processed by the resource merger.

Ref: https://developer.android.com/guide/topics/resources/providing-resources#table1
Ref: https://developer.android.com/guide/topics/resources/more-resources#Xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant