构建 Android 版 Discourse Hub 失败

我正在 macOS 上尝试构建 DiscourseHub,以调试 Forum entries jump on Android app after opening the app - #5 by trs80 。经过一番努力,我终于设置好了构建环境(说明文档中显然遗漏了安装 Java 和 Android Studio 的步骤 Set Up Your Environment · React Native ),但运行 npx react-native run-android 时出现以下错误:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/james/Software/discoursemobile/android/app/build.gradle' line: 88

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'MYAPP_VERSION' for DefaultConfig$AgpDecorated_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=26, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=35, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=243, versionName=null, applicationId=com.discourse, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], buildConfigFields={}, resValues={}, proguardFiles=[], consumerProguardFiles=[], manifestPlaceholders={}, wearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig$AgpDecorated.

这看起来应该是一个简单的修复,但我不知道在哪里修改。另外,鉴于这是一个全新检出的代码库,理论上应该能直接运行成功。关于这是什么原因,大家有什么看法吗?

我想真正的问题是:在过去9年里,有没有人完全不用 Fastlane 直接构建过这个应用?

此外,CDCK 以外的人也无法使用 Fastlane 进行构建,因为它需要访问 KEYS_REPOSITORY = “git@github.com:discourse-org/discourse-mobile-keys.git”

所以我对 android/app/build.gradle 做了足够的修改,现在可以构建成功了。也许值得更新一下 README,说明如何在不使用任何密钥的情况下为本地测试进行构建。

我通过在 build.gradle 中注释掉 apply plugin: 'com.google.gms.google-services' 成功完成了构建,因为 google-services.json 也位于密钥仓库中,但随后它在运行时失败,因为无法初始化 Firebase。让我们注释掉 js/platforms/firebase.android.js 和 js/Discourse.js 中与 Firebase 相关的任何内容。好的,现在可以运行了。

回到最初的问题,登录会按预期弹出 Firefox,但在应用内浏览器中使用的是 Chrome 标签页。这个问题我另找时间再看。