Building discourse hub for Android fails

AI-generated summary

trs80 reports difficulties building the DiscourseHub Android app on macOS, encountering a Gradle error: Could not get unknown property 'MYAPP_VERSION'. The user notes that setup instructions miss key steps like installing Java and Android Studio. They question if anyone has successfully built the app directly (outside of Fastlane) in recent years, highlighting that Fastlane requires access to a private discourse-mobile-keys repository, making external builds impossible without those secrets.

trs80 suggests updating the README to include instructions for building the app locally without proprietary keys. They managed to bypass the initial build error by modifying android/app/build.gradle.

trs80 further details the hack needed to get a runtime build: commenting out the com.google.gms.google-services plugin in build.gradle (due to missing google-services.json) and disabling Firebase initialization in js/platforms/firebase.android.js and js/Discourse.js. While the app now runs, the original bug—where the in-app browser uses a Chrome Custom Tab instead of Firefox—persists and remains under investigation.

I’m trying to build DiscourseHub on macOS to debug Forum entries jump on Android app after opening the app - #5 by trs80 and after some effort I got the build environment set up (the instructions notably miss installing Java and Android Studio Set Up Your Environment · React Native ), but running npx react-native run-android gets me

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.

which seems like it should be a simple fix but I don’t know where to do it and also it should just work given this is a fresh checkout. Any thoughts on what’s going on?

I guess really the question is has anyone built the app directly without using Fastlane in the past 9 years?

And further, nobody outside CDCK can build with Fastlane because it requires access to KEYS_REPOSITORY = “git@github.com:discourse-org/discourse-mobile-keys.git”

So I hacked up android/app/build.gradle sufficiently and now it’s building. Perhaps it’s worth updating the readme to say how to build it without any secrets for local testing.

Well, I got it to build by commenting out apply plugin: 'com.google.gms.google-services' in build.gradle because google-services.jsonalso lives in the keys repository, but then it fails at runtime because it can’t initialise Firebase. Let’s comment out anything to do with Firebase in js/platforms/firebase.android.js and js/Discourse.js, ok it’s running now.

Back to the original problem, login pops Firefox as desired, but the in-app browser uses a Chrome tab. Which I will look at another time.