expo的环境变量管理相关问题
原生配置和expo配置间的一些优先级问题
EAS Build打包时出现这个提示:
expo eas build时出现提示:Loaded "env" configuration for the "production" profile: EXPO_PUBLIC_REVENUE_CAT_API_KEY_IOS, EXPO_PUBLIC_REVENUE_CAT_API_KEY_ANDROID, EXPO_PUBLIC_MOONSHOT_BASE_URL. Learn more
Specified value for "android.package" in app.config.js or app.json is ignored because an android directory was detected in the project.
EAS Build will use the value found in the native code.
首先,提示的第一部分是:
Loaded "env" configuration for the "production" profile: EXPO_PUBLIC_REVENUE_CAT_API_KEY_IOS, EXPO_PUBLIC_REVENUE_CAT_API_KEY_ANDROID, EXPO_PUBLIC_MOONSHOT_BASE_URL.
这意味着 Expo 已正确加载了你为 "production" 环境配置的 env 变量。这部分的提示表明你的环境变量(如 EXPO_PUBLIC_REVENUE_CAT_API_KEY_IOS 等)已经被加载 ,并且将在构建过程中使用。
因此,app.json 中的 env 配置仍然有效,尤其是这些公共的环境变量 (EXPO_PUBLIC_*)。它们会在构建时被读取并注入到你的应用中。
第二部分的提示是:
Specified value for "android.package" in app.config.js or app.json is ignored because an android directory was detected in the project.
EAS Build will use the value found in the native code.
这句话的意思是,尽管你在 app.json 或 app.config.js 中指定了 android.package,但由于你的项目中已经存在 android 目录(即你已经弹出到 Expo 管理的原生代码之外),EAS Build 将忽略 app.json 中的 android.package 配置,并优先使用位于原生代码中的包名配置(通常是在 android/app/src/main/AndroidManifest.xml 文件中定义的 package 属性)。
因此,除了 android.package 之外,其他的配置项(如环境变量)仍然可以在 app.json 中继续生效。