You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Codemagic预构建Firebase配置报错:文件不存在,疑$FCI_BUILD_DIR异常

Troubleshooting "No such file or directory" Error for Firebase Config in Codemagic Pre-build Script

I’ve run into similar path-related issues with Codemagic’s environment variables before, so let’s break down how to debug this step by step:

  • First, verify what FCI_BUILD_DIR actually points to
    Add a debug line at the start of your pre-build script to print the variable’s value:

    echo "FCI_BUILD_DIR is set to: $FCI_BUILD_DIR"
    

    When the build runs, check the logs to confirm it’s pointing to /Users/builder/clone (the standard Codemagic clone directory). If it’s empty or wrong, you might have accidentally renamed this variable without updating the script, or the variable isn’t being injected correctly by Codemagic.

  • Double-check your variable renaming and file write command
    Since you renamed variables from the original guide, make sure the environment variable holding your Firebase config content matches exactly what you’ve set in Codemagic’s dashboard. For example, if you renamed FIREBASE_ANDROID_CONFIG to MY_ANDROID_FIREBASE_CONFIG, your write command should be:

    echo "$MY_ANDROID_FIREBASE_CONFIG" > "$FCI_BUILD_DIR/android/app/google-services.json"
    

    A typo here (like a missing underscore or wrong case) will result in writing an empty file—or failing to write it entirely—leading to the "no such file" error.

  • Confirm the target directory exists
    It’s possible the android/app path doesn’t exist yet (unlikely, but worth checking). Add this line before writing the file to create the directory if needed:

    mkdir -p "$FCI_BUILD_DIR/android/app"
    
  • Add a post-write verification step
    After writing the file, check if it actually exists to narrow down the issue:

    if [ -f "$FCI_BUILD_DIR/android/app/google-services.json" ]; then
        echo "✅ google-services.json created successfully"
        # Optional: Print the first few lines to confirm content
        head "$FCI_BUILD_DIR/android/app/google-services.json"
    else
        echo "❌ Failed to create google-services.json"
    fi
    

Most often, this error boils down to a misspelled variable name or a mismatch between the environment variable you defined in Codemagic and the one you’re using in your script. The debug lines will make it obvious where the breakdown is happening.

内容的提问来源于stack exchange,提问作者oodavid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 08:27:42