All Projects β†’ dimagi β†’ commcare-android

dimagi / commcare-android

Licence: Apache-2.0 license
Offline First Android software client for CommCare, the world's largest platform for designing, managing, and deploying robust mobile applications to frontline workers worldwide

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
kotlin
9241 projects
python
139335 projects - #7 most used programming language
shell
77523 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to commcare-android

briefcase
ODK Briefcase is a Java application for fetching and pushing forms and their contents. It helps make billions of data points from ODK portable. Contribute and make the world a better place! βœ¨πŸ’Όβœ¨
Stars: ✭ 62 (+148%)
Mutual labels:  global-development, global-health, xforms, social-impact, mobile-data-collection
central-frontend
Vue.js based frontend for ODK Central
Stars: ✭ 24 (-4%)
Mutual labels:  global-development, global-health, mhealth, social-impact
xforms-spec
The XForms-derived specification used in the ODK ecosystem. If you are interested in building a tool that is compliant with the forms rendered by ODK tools, this is the place to start. βœ¨βš’βœ¨
Stars: ✭ 27 (+8%)
Mutual labels:  global-development, global-health
ITF Power BI
Contains functions for pulling publicly-available global COVID-19 case and testing data for analysis and populating a Power BI dashboard.
Stars: ✭ 15 (-40%)
Mutual labels:  global-health
tiptoft
Predict plasmids from uncorrected long read data
Stars: ✭ 27 (+8%)
Mutual labels:  global-health
gubbins
Rapid phylogenetic analysis of large samples of recombinant bacterial whole genome sequences using Gubbins
Stars: ✭ 103 (+312%)
Mutual labels:  global-health
cht-android
A native Android container for Community Health Toolkit (CHT) applications
Stars: ✭ 21 (-16%)
Mutual labels:  mhealth
phd-resources
Internet Delivered Treatment using Adaptive Technology
Stars: ✭ 37 (+48%)
Mutual labels:  mhealth
numishare
Numishare is an open source suite of applications for managing digital cultural heritage artifacts, with a particular focus on coins and medals.
Stars: ✭ 29 (+16%)
Mutual labels:  xforms
cht-gateway
Android SMS gateway app for CHT Applications
Stars: ✭ 60 (+140%)
Mutual labels:  mhealth
cht-conf
A command-line interface for configuring Community Health Toolkit applications
Stars: ✭ 20 (-20%)
Mutual labels:  mhealth
gff3toembl
Converts Prokka GFF3 files to EMBL files for uploading annotated assemblies to EBI
Stars: ✭ 27 (+8%)
Mutual labels:  global-health
Food-Categories-Classification
This repository contains the dataset and the source code for the classification of food categories from meal images.
Stars: ✭ 48 (+92%)
Mutual labels:  mhealth
plasmidtron
Assembling the cause of phenotypes and genotypes from NGS data
Stars: ✭ 27 (+8%)
Mutual labels:  global-health
mlst check
Multilocus sequence typing by blast using the schemes from PubMLST
Stars: ✭ 22 (-12%)
Mutual labels:  global-health
saffrontree
SaffronTree: Reference free rapid phylogenetic tree construction from raw read data
Stars: ✭ 17 (-32%)
Mutual labels:  global-health
snp-sites
Finds SNP sites from a multi-FASTA alignment file
Stars: ✭ 182 (+628%)
Mutual labels:  global-health
assembly improvement
Improve the quality of a denovo assembly by scaffolding and gap filling
Stars: ✭ 46 (+84%)
Mutual labels:  global-health
flirt
Are you ready to FLIRT with your wearable data?
Stars: ✭ 41 (+64%)
Mutual labels:  mhealth
community-sprints
This repo is used to organize and collaborate in sprints for code projects, hackathons, STAC and metadata specs development
Stars: ✭ 18 (-28%)
Mutual labels:  global-development

commcare-android

CommCare is an easily customizable, open source mobile platform that supports frontline workers in low-resource settings. By replacing paper-based forms, frontline workers can use CommCare to track and support their clients with registration forms, checklists, SMS reminders, and multimedia.

This repository represents the Android version of CommCare. It depends on the CommCare Core repository, which contains the XForm engine and case/lookup table implementations.

Setup

To set up an Android dev environmnet for commcare-android, do the following:

  • Install Android Studio.
  • Install Java 8 if you don't have it yet. For ease of test suite setup (see below) OpenJDK is preferred over Oracle's version of Java.

Go ahead and open Android Studio if this is your first time using it; it may take you through some sort of setup wizard, and it's nice to get that out of the way.

Android Studio's default project space is ~/AndroidStudioProjects so I'm going to use that in the example. CommCare Android depends on CommCare Core, and CommCare Android expects the core directory to live side by side in your directory structure. You can acheive this with the following commands (in bash):

cd ~/AndroidStudioProjects
mkdir CommCare
cd CommCare
git clone https://github.com/dimagi/commcare-android.git
git clone https://github.com/dimagi/commcare-core.git
  • Open Android Studio
  • If this is your first time using Android Studio, click "Config" and setup the Android SDK.
  • Download the Android 7 (API 24) SDK Platform and the Google APIs for 24.
  • Now go back to the Android Studio Welcome dashboard and click "Import project (Eclipse ADT, Gradle, etc.)"
  • Select AndroidStudioProjects > CommCare > commcare-android and hit OK
  • Click "OK" to use the Gradle wrapper
  • Wait while Android Studio spins its wheels
  • Download any build dependencies that the SDK Manager tells you you need.
  • Disable Instant Run found in Settings > Build, Execution, Deployment > Instant Run. (It does not play well with multidexing, which we have enabled, or with some of the processes we have set up for Google Services)

Building

Now you're basically ready to go. To build CommCare Android and get it running on your phone, plug in an android phone that

In Android Studio, hit the build button (a green "play" symbol in the toolbar). The first build will take a minute. Then it'll ask you what device to run it on

  • Make sure your screen is unlocked (or else you'll see something like this)
  • select your device

Enjoy!

Building from the command-line

CommCare has several different build variants. The normal build variant is commcare and can built built from the command-line with the following command:

cd commcare-android
./gradlew assembleCommcareDebug
# the apk can now be found in the build/outputs/apk/ directory

Unit Tests

The commcare-android repository uses Robolectric, which provides mocks, allowing you to run Android specific code on your local machine.

Run unit-tests from the command-line

cd commcare-android
./gradlew testCommcareDebug

and view the results from the output file generated.

Run unit-tests from Android Studio

Create a new Android Studio JUnit Build configuration using the following steps.

  • Click Run -> Edit Configruations and create a new JUnit configuration by pressing the green plus button.
  • Set Name to "commcare android test suite"
  • Set Test kind to "All in directory"
  • set Directory to /absolute/path/to/commcare-android/app/unit-tests/src/
  • Right click on this directory and click the "Create 'All Tests'" option that should be listed more than half-way down the list.
  • Set VM options to -ea -noverify
  • Set Working directory to /absolute/path/to/commcare-android/app/
  • Set Use classpath of module to app
  • Click OK to finish creating the configuration.
  • Select the "commcare android test suite" under the configuration drop down to the left of the green play button.
  • Press the green play button to run the tests.

Instrumentation Tests

The commcare-android repository uses Espresso to write UI tests. You need to have two keys in your gradle.properties before being able to run any instrumentation tests. But make sure you never commit these keys to github.

HQ_API_USERNAME=<ASK_ANOTHER_DEV_FOR_KEY>
HQ_API_PASSWORD=<ASK_ANOTHER_DEV_FOR_KEY>

Run instrumentation-tests from the command-line

cd commcare-android
./gradlew connectedCommcareDebugAndroidTest

It's also a common requirement to run a particular test, such as when you’re fixing a bug or developing a new test. You can achieve the same in command-line using:

./gradlew connectedCommcareDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=<FULLY_QUALIFIED_NAME_OF_YOUR_TEST>

You can view the results from the output file generated.

Run instrumentation-tests from Android Studio

Before running tests from Android-Studio make sure you've disabled animations in your device. Note, this is only required when you're running tests from Android Studio

Go to Setting -> Developer Options, and under the Drawing section, switch all of the following options:

Window animation scale -> off
Transition animation scale -> off
Animator duration scale -> off

Create a new Android Studio Android Instrumented Test Build configuration using the following steps.

  • Click Run -> Edit Configruations and create a new Android Instrumented Test configuration by pressing the green plus button.
  • Set Name to "commcare android instrumentation tests"
  • Set Test kind to "All in Package"
  • set Package to org.commcare.androidTests
  • Click OK to finish creating the configuration.
  • Select the "commcare android instrumentation tests" under the configuration drop down to the left of the green play button.
  • Press the green play button to run the tests.

Run instrumentation-tests skipped on browserstack

cd commcare-android
./gradlew connectedCommcareDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.notAnnotation=org.commcare.annotations.BrowserstackTests

Code Style Settings

In order to comply with code style guidelines we follow, please use Commcare Coding Style file and Commcare Inspection Profile as your respective code style and inpection profile in Android Studio. To do so follow these instructions

  1. Copy the config files to your Android Studio installation as follows (Replace AndroidStudio3.0 with the respective directory for the AS version you are using) -
cp .android_studio_settings/inspection/CommCare\ Inpsection\ Profile.xml ~/Library/Preferences/AndroidStudio3.0/inspection/.

cp .android_studio_settings/codestyles/CommCare\ Coding\ Style.xml ~/Library/Preferences/AndroidStudio3.0/codestyles/.  

  1. Restart Android Studio

  2. Go to AS preferences -> Editor -> Code Style and select Scheme as 'Commcare Coding Style' and to AS preferences -> Editor -> Inspections and select Profile as 'Commcare Inspection Profile'

Common Errors

If you experience the following exception when running the tests:

java.security.InvalidKeyException: Illegal key size or default parameters

you will need to upgrade the JCE policy files that are being used. To do so:

  1. Download the JCE Unlimited Strength policy files for Java 8 (Last we checked they could be found here, but this can change
  2. Find the java home directory on your machine. On mac you can do so by entering the following into the command line: echo $(/usr/libexec/java_home)
  3. From there, cd into jre/lib/security, and replace the local_policy.jar and US_export_policy.jar files found there with the ones in the zip file you downloaded

NOTE that if you are running the tests from Android Studio, it may be using a different version of Java than that in your java home directory. The first line of the test output will usually show the directory from which Android Studio is running Java (Usually /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/security). If it is indeed different, you should follow the steps above for that directory as well.

If you experience the following exception when running individual tests from Android Studio Editor on Mac

No such manifest file: build/intermediates/bundles/debug/AndroidManifest.xml

If you are on a Mac, you will probably need to configure the default JUnit test runner configuration in order to work around a bug where IntelliJ / Android Studio does not set the working directory to the module being tested. This can be accomplished by editing the run configurations, Defaults -> JUnit and changing the working directory value to $MODULE_DIR$

Error on attempt to install CommCare app on phone: Unknown failure during app install

Android Monitor in Android Studio shows the following exceptions:

java.lang.RuntimeException: CommCare ran into an issue deserializing data while inflating type
    ...
Caused by: org.javarosa.core.util.externalizable.DeserializationException:
No datatype registered to serialization code [4b a9 e5 89]

Resolution:

  • Disable Instant Run found in Settings > Build, Execution, Deployment > Instant Run.

  • Maybe also edit ~/.gradle/gradle.properties (may not exist) and add a line like org.gradle.jvmargs=-Xmx1536M if the build fails due to OOM or you see a message like the following during the build:

    To run dex in process, the Gradle daemon needs a larger heap.
    It currently has 1024 MB.
    For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
    To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
    
  • Click Run 'app' to rebuid and run on phone.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].