fix(expo-plugin): move android_initialisation_config.xml to res/xml/#97
Open
abh1abii wants to merge 1 commit intomoengage:masterfrom
Open
fix(expo-plugin): move android_initialisation_config.xml to res/xml/#97abh1abii wants to merge 1 commit intomoengage:masterfrom
abh1abii wants to merge 1 commit intomoengage:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Expo config plugin incorrectly copies
android_initialisation_config.xmlinto
android/app/src/main/res/values/. This causes a hard build failure duringthe
packageDebugResources/packageReleaseResourcesGradle task for all usersof 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 tobuild/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, andevery child element must be a recognised Android resource type (
<string>,<color>,<dimen>, etc.).android_initialisation_config.xmluses<MoEngageConfiguration>as its root,which the resource merger cannot type-check — hence the
Can't determine type for tagerror.From the official Android documentation on
res/values/:The correct directory is
res/xml/, which is explicitly designed forarbitrary XML files read at runtime:
From the official Android documentation on
res/xml/:The MoEngage Android SDK reads
android_initialisation_config.xmlvia its ownXML parser — not through Android's
<resources>system — makingres/xml/thesemantically and technically correct location.
Change
src/android/constants.ts: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
in app.json plugins.
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:
References
https://developer.android.com/guide/topics/resources/providing-resources#table1