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
|
|| sThemeImplThemeKeyField == null
|
||||||
|| sThemeKeyResIdField == null
|
|| sThemeKeyResIdField == null
|
||||||
|| sThemeImplAssetManagerField == null) {
|
|| sThemeImplAssetManagerField == null) {
|
||||||
sThemeImplField = theme.getClass().getDeclaredField("mThemeImpl");
|
|
||||||
sThemeImplField.setAccessible(true);
|
|
||||||
|
|
||||||
themeImpl = sThemeImplField.get(theme);
|
// Early exiting as this bit of code causes too much of the metadata to be created and
|
||||||
sThemeImplThemeKeyField = themeImpl.getClass().getDeclaredField("mKey");
|
// ultimately leads to out of memory exception. Reference D20441839
|
||||||
sThemeImplThemeKeyField.setAccessible(true);
|
// sThemeImplField = theme.getClass().getDeclaredField("mThemeImpl");
|
||||||
|
// sThemeImplField.setAccessible(true);
|
||||||
|
|
||||||
sThemeImplAssetManagerField = themeImpl.getClass().getDeclaredField("mAssets");
|
// themeImpl = sThemeImplField.get(theme);
|
||||||
sThemeImplAssetManagerField.setAccessible(true);
|
// sThemeImplThemeKeyField = themeImpl.getClass().getDeclaredField("mKey");
|
||||||
|
// sThemeImplThemeKeyField.setAccessible(true);
|
||||||
|
|
||||||
sAssetManagerGetStyleAttributesMethod =
|
// sThemeImplAssetManagerField = themeImpl.getClass().getDeclaredField("mAssets");
|
||||||
assetManager.getClass().getDeclaredMethod("getStyleAttributes", int.class);
|
// sThemeImplAssetManagerField.setAccessible(true);
|
||||||
sAssetManagerGetStyleAttributesMethod.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 {
|
} else {
|
||||||
themeImpl = sThemeImplField.get(theme);
|
themeImpl = sThemeImplField.get(theme);
|
||||||
themeKey = sThemeImplThemeKeyField.get(themeImpl);
|
themeKey = sThemeImplThemeKeyField.get(themeImpl);
|
||||||
@@ -77,6 +83,9 @@ public final class ContextDescriptorUtils {
|
|||||||
TypedValue typedValue = new TypedValue();
|
TypedValue typedValue = new TypedValue();
|
||||||
Resources resources = context.getResources();
|
Resources resources = context.getResources();
|
||||||
for (int themeId : appliedThemeResIds) {
|
for (int themeId : appliedThemeResIds) {
|
||||||
|
if (themeId == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String name = resources.getResourceName(themeId);
|
String name = resources.getResourceName(themeId);
|
||||||
// The res id array can have duplicates
|
// The res id array can have duplicates
|
||||||
if (builderMap.containsKey(name)) {
|
if (builderMap.containsKey(name)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user