I am working on a project which I plan to opensource. The app will use a crash detection library which to initialise requires an API key and app key in order to initialise and send th crash data to the service.

I obviously don't want to publish these keys into the open source repository so I was wondering what the best way of doing it is.

I was thinking my development environment could contain an environment variable which contains the API and App Key and the gradle file checks if the environment variable is set, and if so it updates a string resource value with the environment variable value and the library calls activity.getString(R.id.string_key) and if this is not set, it doesn't initialise the crash detection library.

Is this the best way of doing it, or is there a better alternative?

  • 2
    The best way would be to make use of the crash detection library optional. If the user wants to use his own API key with that service, let him. If not, let him run it without the service.
    – Brandin
    Apr 26, 2018 at 14:22
  • 5
    Possible duplicate of Non-public data in GPL project
    – MadHatter
    Apr 26, 2018 at 15:04
  • The open source project won't be allowed to re-distribute the app elsewhere, it will only be myself publishing it to the play store, the crash detection library is required for production but it won't be/shouldn't be used under development
    – Boardy
    Apr 26, 2018 at 17:07
  • 3
    "The open source project won't be allowed to re-distribute the app elsewhere," Then it is neither Open Source nor Free Software.
    – user10225
    Apr 26, 2018 at 19:36
  • 1
    Ok forget that bit, I had a misunderstanding there, they can re-distribute it but if someone contributes to the project for it to get published as official it will have to be done by myself - which means it will require the crash library API, but obviously wouldn't want to give that to contributors. I was planning something along the lines of is if the API key is not set (possible from environment variable) then don't initialise the library.
    – Boardy
    Apr 26, 2018 at 20:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.