android: property "compileSdkVersion" cannot be found or does not have a numeric value.
Hi! I'm using the plugin for react-native-nfc-manager and this is my plugin config:
[
"react-native-nfc-manager",
{
"nfcPermission": "The app needs to be able to read NFC tags so that it can start or end employees' turns",
"includeNdefEntitlement": false
}
],
If I'm using the plugin, when running npx expo prebuild I get the warning
android: withBuildScriptExtVersion: Cannot set minimum buildscript.ext.compileSdkVersion version because the property "compileSdkVersion" cannot be found or does not have a numeric value..
If I remove the plugin, the warning is gone... However I need the plugin.
Is it possible to fix this annoying warning? It doesn't seem like it is making something break, but it would be nice to fix it.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
We are also seeing this warning with Expo 52.0.33 react-native-nfc-manager 3.16 and "react-native-nfc-manager" added to 'plugins'
We are also seeing this warning with Expo 53.0.22 react-native-nfc-manager 3.16.3 and "react-native-nfc-manager" added to 'plugins'
The plugin uses AndroidConfig.Version.withBuildScriptExtMinimumVersion which crashes when compileSdkVersion doesn't exist. This is a known issue in Expo with a TODO acknowledging it should handle missing properties.
Option 1: Wrap in try-catch
try {
config = AndroidConfig.Version.withBuildScriptExtMinimumVersion(config, {
name: 'compileSdkVersion',
minVersion: 31,
});
} catch {
// Silently continue - expo-build-properties handles the SDK version
}
Option 2: Use withProjectBuildGradle directly
const { withProjectBuildGradle } = require('@expo/config-plugins');
// Replace the problematic section with:
config = withProjectBuildGradle(config, (config) => {
if (config.modResults.language === 'groovy') {
const contents = config.modResults.contents;
const match = contents.match(/compileSdkVersion\s*=\s*(\d+)/);
if (match && parseInt(match[1]) < 31) {
config.modResults.contents = contents.replace(
/compileSdkVersion\s*=\s*\d+/,
'compileSdkVersion = 31'
);
}
}
return config;
});
Option 3: Require explicit configuration (recommended)
Instead of silently modifying SDK versions, throw a clear error requiring users to configure expo-build-properties with android.compileSdkVersion >= 31. This follows modern Expo patterns where apps explicitly declare their build configuration rather than libraries modifying it silently.
After patching: npx expo prebuild --clean should no longer warn.
@whitedogg13 can you reopen this issue?
@trentrand sure, I will reopen it and welcome to make a PR when you find the solution!
expo 54 use version 36 so i think it's overkill to overwrite the value in the plugin. checking it's high enough and throw if not seems like the best approach.