Search code examples
fluttercodemagic

Codemagic WARNING: ignoring settings from 'local.properties'


In codemagic workflow editor I can see this at the bottom of get dependencies task:

WARNING: ignoring settings from 'local.properties'!

I believe this is causing

Cannot invoke method toInteger() on null object

while building android, because that error occurs when minSdkVersion is below 21 and my local.properties file sets it to 21.

I've tried to fix it by adding this post-clone script which apparently sets the local properties:

#!/bin/sh
# set up local properties
echo "flutter.sdk=$HOME/programs/flutter" > "$CM_BUILD_DIR/android/local.properties"

It doesn't work. I don't know if that is where the flutter.sdk is on the codemagic server. I just saw exactly that script in a few different places. Any ideas why it is not working? I am building it on codemagic’s mac.


Solution

  • check android > defaultConfig section in your build.gradle file. You should be able to see something like next lines

    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
    minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
    targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
    

    Since you don't have those properties defined in your local.properties file hence the error.

    You can set minSdkVersion / targetSdkVersion directly in build.gradle file. Otherwise you need to add missed properties to local.properties file. Something like this in the post-clone script:

    #!/bin/sh
    # set up local properties
    echo "flutter.sdk=$HOME/programs/flutter" > "$CM_BUILD_DIR/android/local.properties"
    echo "flutter.minSdkVersion=21" >> "$CM_BUILD_DIR/android/local.properties"
    echo "flutter.targetSdkVersion=21" >> "$CM_BUILD_DIR/android/local.properties"
    

    notice that 2nd and 3rd lines use >> to append lines to the file.