Fix the broken export of layout plugin in android(not easily reproducible)
Summary: There was a bug reported recently where the fetching all the nodes failed and the error is pasted [here](https://our.intern.facebook.com/intern/paste/P127476330/). From the paste we can see this `android.content.res.Resources$NotFoundException: Unable to find resource ID #0x0`. Reported bug is [here](https://fb.workplace.com/groups/flippersupport/permalink/830359447444715/) I was able to repro this luckily {F231474948} Reviewed By: xiphirx Differential Revision: D20441839 fbshipit-source-id: 9e9bfd15422c0f6c6f7a71aa22e9b1c8d640ec4a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
90ad50f714
commit
cfb82ad8c8
@@ -51,23 +51,29 @@ public final class ContextDescriptorUtils {
|
||||
|| sThemeImplThemeKeyField == null
|
||||
|| sThemeKeyResIdField == null
|
||||
|| sThemeImplAssetManagerField == null) {
|
||||
sThemeImplField = theme.getClass().getDeclaredField("mThemeImpl");
|
||||
sThemeImplField.setAccessible(true);
|
||||
|
||||
themeImpl = sThemeImplField.get(theme);
|
||||
sThemeImplThemeKeyField = themeImpl.getClass().getDeclaredField("mKey");
|
||||
sThemeImplThemeKeyField.setAccessible(true);
|
||||
// Early exiting as this bit of code causes too much of the metadata to be created and
|
||||
// ultimately leads to out of memory exception. Reference D20441839
|
||||
// sThemeImplField = theme.getClass().getDeclaredField("mThemeImpl");
|
||||
// sThemeImplField.setAccessible(true);
|
||||
|
||||
sThemeImplAssetManagerField = themeImpl.getClass().getDeclaredField("mAssets");
|
||||
sThemeImplAssetManagerField.setAccessible(true);
|
||||
// themeImpl = sThemeImplField.get(theme);
|
||||
// sThemeImplThemeKeyField = themeImpl.getClass().getDeclaredField("mKey");
|
||||
// sThemeImplThemeKeyField.setAccessible(true);
|
||||
|
||||
sAssetManagerGetStyleAttributesMethod =
|
||||
assetManager.getClass().getDeclaredMethod("getStyleAttributes", int.class);
|
||||
sAssetManagerGetStyleAttributesMethod.setAccessible(true);
|
||||
// sThemeImplAssetManagerField = themeImpl.getClass().getDeclaredField("mAssets");
|
||||
// sThemeImplAssetManagerField.setAccessible(true);
|
||||
|
||||
// sAssetManagerGetStyleAttributesMethod =
|
||||
// assetManager.getClass().getDeclaredMethod("getStyleAttributes", int.class);
|
||||
// sAssetManagerGetStyleAttributesMethod.setAccessible(true);
|
||||
|
||||
// themeKey = sThemeImplThemeKeyField.get(themeImpl);
|
||||
// sThemeKeyResIdField = themeKey.getClass().getDeclaredField("mResId");
|
||||
// sThemeKeyResIdField.setAccessible(true);
|
||||
|
||||
return builderMap;
|
||||
|
||||
themeKey = sThemeImplThemeKeyField.get(themeImpl);
|
||||
sThemeKeyResIdField = themeKey.getClass().getDeclaredField("mResId");
|
||||
sThemeKeyResIdField.setAccessible(true);
|
||||
} else {
|
||||
themeImpl = sThemeImplField.get(theme);
|
||||
themeKey = sThemeImplThemeKeyField.get(themeImpl);
|
||||
@@ -77,6 +83,9 @@ public final class ContextDescriptorUtils {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
Resources resources = context.getResources();
|
||||
for (int themeId : appliedThemeResIds) {
|
||||
if (themeId == 0) {
|
||||
continue;
|
||||
}
|
||||
String name = resources.getResourceName(themeId);
|
||||
// The res id array can have duplicates
|
||||
if (builderMap.containsKey(name)) {
|
||||
|
||||
Reference in New Issue
Block a user