Android
Requirements
- Android Studio - Latest stable version
- Android SDK - For the SDK Platform version, refer to the
compileSdk
version in the libs.versions.toml file
Setup
-
Clone the repository:
$ git clone https://github.com/bitwarden/android
-
Create a
user.properties
file in the root directory of the project and add the following properties:gitHubToken
: A "classic" Github Personal Access Token (PAT) with theread:packages
scope (ex:gitHubToken=gph_xx...xx
). These can be generated by going to the Github tokens page. See the Github Packages user documentation concerning authentication for more details.localSdk
: A boolean value to determine if the SDK should be loaded from the local maven artifactory (ex:localSdk=true
). This is particularly useful when developing new SDK capabilities. Review Linking SDK to clients for more details.
-
Setup the code style formatter:
All code must follow the guidelines described in the Code Style Guidelines document. To aid in adhering to these rules, all contributors should apply
docs/bitwarden-style.xml
as their code style scheme. In IntelliJ / Android Studio:- Navigate to
Preferences > Editor > Code Style
. - Hit the
Manage
button next toScheme
. - Select
Import
. - Find the
bitwarden-style.xml
file in the project'sdocs/
directory. - Import "from"
BitwardenStyle
"to"BitwardenStyle
. - Check the box,
Enable EditorConfig support
. - Hit
Apply
andOK
to save the changes and exit Preferences.
Note that in some cases you may need to restart Android Studio for the changes to take effect.
All code should be formatted before submitting a pull request. This can be done manually but it can also be helpful to create a macro with a custom keyboard binding to auto-format when saving. In Android Studio on OS X:
- Select
Edit > Macros > Start Macro Recording
- Select
Code > Optimize Imports
- Select
Code > Reformat Code
- Select
File > Save All
- Select
Edit > Macros > Stop Macro Recording
This can then be mapped to a set of keys by navigating to
Android Studio > Preferences
and editing the macro underKeymap
(ex : shift + command + s).Please avoid mixing formatting and logical changes in the same commit/PR. When possible, fix any large formatting issues in a separate PR before opening one to make logical changes to the same code. This helps others focus on the meaningful code changes when reviewing the code.
- Navigate to
-
Install fastlane for automated package deployments:
Note We manage non-system Ruby installations with
rbenv
as homebrew tends to break the required Ruby dependencies$ brew install rbenv
$ rbenv initFrom the root directory of the
android
repo do the following:$ rbenv install -s
$ bundle installNote If
bundle install
fails you may need to restart your shell orsource
your appropriate profile to recognize the newly installed non-system Ruby, e.g.source ~/.zprofile
thenbundle install
againOnce complete you can test fastlane with:
$ bundle exec fastlane --version
When necessary, update the Ruby version with:
$ rbenv install 3.4.4
Update dependencies with:
$ bundle update
If you're still having issues, here are some helpful commands for troubleshooting:
$ which -a ruby
$ which -a rbenv
$ which -a fastlane
$ rbenv which fastlane
$ echo $PATH
Dependencies
For Application, Development Environment, and CI/CD dependencies, refer to the libs.versions.toml file.