Skip to content

Instantly share code, notes, and snippets.

@Randall71
Created June 20, 2025 18:08
Show Gist options
  • Select an option

  • Save Randall71/695f5ced1123dcce484b985484a2a167 to your computer and use it in GitHub Desktop.

Select an option

Save Randall71/695f5ced1123dcce484b985484a2a167 to your computer and use it in GitHub Desktop.
Config Plugin to just build expo app for specific architectures of processor (armeabi-v7a, arm64-v8a, x86, x86-64)
const { withGradleProperties, withAppBuildGradle } = require('@expo/config-plugins');
const withAbiFilters = (config, { abiFilters = ['arm64-v8a'] } = {}) => {
console.log('🔧 ABI Filter plugin is running!', abiFilters);
// Set gradle.properties
config = withGradleProperties(config, (config) => {
// Convert array to comma-separated string for gradle.properties
const architecturesString = abiFilters.join(',');
// Set the reactNativeArchitectures property
config.modResults = config.modResults.filter(
(item) => !item.key || item.key !== 'reactNativeArchitectures',
);
config.modResults.push({
type: 'property',
key: 'reactNativeArchitectures',
value: architecturesString,
});
return config;
});
// Set build.gradle ndk.abiFilters
config = withAppBuildGradle(config, (config) => {
const abiFiltersString = abiFilters.map((abi) => `"${abi}"`).join(', ');
// Add ndk abiFilters to defaultConfig
if (config.modResults.contents.includes('defaultConfig {')) {
config.modResults.contents = config.modResults.contents.replace(
/(defaultConfig\s*\{[^}]*versionName\s+[^}]*)/,
`$1
ndk {
abiFilters ${abiFiltersString}
}`,
);
}
return config;
});
return config;
};
module.exports = withAbiFilters;
@diazleonata

Copy link
Copy Markdown

Interesting... I should try this one!

@javilumbrales

javilumbrales commented Jul 29, 2025

Copy link
Copy Markdown

Works perfect! Thx

@tdw94

tdw94 commented Aug 4, 2025

Copy link
Copy Markdown

thanks!

@Drzaln

Drzaln commented Aug 18, 2025

Copy link
Copy Markdown

Works perfecly, many thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment