react-native-nfc-manager icon indicating copy to clipboard operation
react-native-nfc-manager copied to clipboard

android: property "compileSdkVersion" cannot be found or does not have a numeric value.

Open giovanni-caiazzo opened this issue 1 year ago • 8 comments

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.

giovanni-caiazzo avatar Oct 16 '24 12:10 giovanni-caiazzo

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.

github-actions[bot] avatar Jan 15 '25 02:01 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jan 31 '25 02:01 github-actions[bot]

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'

chriswheeler avatar Feb 14 '25 15:02 chriswheeler

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'

superyarik avatar Sep 01 '25 18:09 superyarik

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.

trentrand avatar Sep 19 '25 22:09 trentrand

@whitedogg13 can you reopen this issue?

trentrand avatar Sep 20 '25 19:09 trentrand

@trentrand sure, I will reopen it and welcome to make a PR when you find the solution!

whitedogg13 avatar Sep 21 '25 01:09 whitedogg13

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.

wcastand avatar Oct 14 '25 13:10 wcastand