- Minimum SDK: 29 (Android 10)
- Target SDK: 36 (Android 16)
- Device Types Supported: Phone and Tablet
- Orientations Supported: Portrait and Landscape
-
Clone the repository:
AdvertisementRemove ads, dark theme, and more with
Premium
$ git clone github.com/bitwarden/android
-
Create a
user.propertiesfile in the root directory of the project and add the following properties:gitHubToken: A "classic" Github Personal Access Token (PAT) with theread:packagesscope (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.xmlas their code style scheme. In IntelliJ / Android Studio:- Navigate to
Preferences > Editor > Code Style. - Hit the
Managebutton next toScheme. - Select
Import. - Find the
bitwarden-style.xmlfile in the project'sdocs/directory. - Import "from"
BitwardenStyle"to"BitwardenStyle. - Hit
ApplyandOKto 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 > Preferencesand 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
-
Setup JDK
Version21:- Navigate to
Preferences > Build, Execution, Deployment > Build Tools > Gradle. - Hit the selected Gradle JDK next to
Gradle JDK:. - Select a
21.xversion or hitDownload JDK...if not present. - Select
Version21. - Select your preferred
Vendor. - Hit
Download. - Hit
Apply.
- Navigate to
-
Setup
detektpre-commit hook (optional):
Run the following script from the root of the repository to install the hook. This will overwrite any existing pre-commit hook if present.
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="echo "Writing detekt pre-commit hook..."
cat < .git/hooks/pre-commit
#!/usr/bin/env bash
echo "Running detekt check..."
OUTPUT="/tmp/detekt-$(date +%s)"
./gradlew -Pprecommit=true detekt > $OUTPUT
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
cat $OUTPUT
rm $OUTPUT
echo "***********************************************"
echo " detekt failed "
echo " Please fix the above issues before committing "
echo "***********************************************"
exit $EXIT_CODE
fi
rm $OUTPUT
EOL
echo "detekt pre-commit hook written to .git/hooks/pre-commit"
echo "Making the hook executable"
chmod +x .git/hooks/pre-commit
echo "detekt pre-commit hook installed successfully to .git/hooks/pre-commit"">
echo "Writing detekt pre-commit hook..." cat << 'EOL' > .git/hooks/pre-commit #!/usr/bin/env bash echo "Running detekt check..." OUTPUT="/tmp/detekt-$(date +%s)" ./gradlew -Pprecommit=true detekt > $OUTPUT EXIT_CODE=$? if [ $EXIT_CODE -ne 0 ]; then cat $OUTPUT rm $OUTPUT echo "***********************************************" echo " detekt failed " echo " Please fix the above issues before committing " echo "***********************************************" exit $EXIT_CODE fi rm $OUTPUT EOL echo "detekt pre-commit hook written to .git/hooks/pre-commit" echo "Making the hook executable" chmod +x .git/hooks/pre-commit echo "detekt pre-commit hook installed successfully to .git/hooks/pre-commit"



























