= agritrader
This project is a mobile application to be used by traders that interact with farmers to collect agricultural goods.
== Development
=== Setting up a Development Environment via Docker
A Docker development environment has been made available, to use it follow the steps below.
IMPORTANT: This does not work on native docker for Windows and OS X. This works natively on Linux and it can work on Docker Toolbox by link:https://gist.github.com/stonehippo/e33750f185806924f1254349ea1a4e68[passing the USB device through to VirtualBox] first.
. Install Docker using the instructions on the link:https://docs.docker.com/engine/installation/[official website]. Do not use a package manager as this results in installing an outdated version of Docker.
. Give executable permissions to the utility script using chmod +x dockerize.sh
.
. Build the image using ./dockerize.sh init
.
This may take a while (15 - 30 minutes).
. Install the node modules using ./dockerize.sh install
.
. Plug in your phone to your computer and allow access to your phone. Allowing access to your phone varies per phone, but is common for a pop-up to show on a device shortly after plugging it in to a computer. Ensure the cable connecting the phone and computer is capable of data transfer and not just power.
lsusb
.
For example the output could be:
+
[source,bash]+
The path would then be /dev/bus/usb/001/055
for the Samsung device (phone).
./dockerize.sh adb-devices /path/to/device/
.
The output should include a device.
+
[source,bash]user@user-pc ~/boresha/agritrader $ ./dockerize.sh adb /dev/bus/usb/001/055 List of devices attached
. Build the package and deploy it to your phone using ./dockerize.sh android /path/to/device
.
This should take a few minutes before anything shows up on your phone.
. Once the app is running on your phone, enable hot reloading by shaking your phone and selecting Enable Hot Reloading.
NOTE: The phone will need to be disconnected and reconnected for every build (./dockerize.sh android /path/to/device
).
Any other actions can be done with the run
action.
./dockerize.sh run
and npm run
are equivalent except that the former runs the environment in docker.
==== Building a Signed APK
. Ensure the image is initalized with ./dockerize.sh init
and dependencies installed with ./dockerize.sh install
.
. Copy gradle.properties.tmpl
in the root directory to the $HOME/.gradle/
directory and rename it to gradle.properties
.
gradle.properties
is the file that will actually be used.
Fill in the AGRITRADER_DEPLOY_UNSTABLE_STORE_PASSWORD
and AGRITRADER_DEPLOY_UNSTABLE_KEY_PASSWORD
fields with the password.
Ask someone for the password, it is not version controlled.
+
IMPORTANT: Be very careful not to commit the passwords to version control.
. Ask for the agritrader-deploy-unstable.keystore
keystore and copy it to the android/app
directory.
The keystore is also not version controlled.
. Build the signed APK using ./dockerize.sh apk
.
. The output file will be android/app/build/outputs/apk/app-release.apk
.
=== Setting up a Development Environment Locally
Follow steps found in the Building Projects with Native Code
tab in the link:https://facebook.github.io/react-native/docs/getting-started.html[React Native documentation for Getting Started] for installing dependencies and setting up the mobile development environment, such as the Android SDK and build tools.
==== Setting up a Device
To try running the code on a device, follow the steps found in the link:https://facebook.github.io/react-native/docs/running-on-device.html[React Native documentation for Running your app on a Device].
==== Common Issues
Make sure the JAVA_HOME
and ANDROID_HOME
environment variables are set.
Make sure the adb
command is available from the terminal.
The sdk platform tools directory may have to be added to the PATH
environment variables.
The platform tools directory can be found in D:\Users\<your username>\AppData\Local\Android\sdk\platform-tools
.
When trying to run the application on a device, make sure a phone is connected.
Use adb devices
to check for a connected device.
==== Running the Application
Once a development environment has been setup, the application can be run with the following steps.
. Clone the repository.
. Run yarn install
to install the dependencies.
. Ensure a device is connected to the computer or an emulator is set up.
. Run npm run start:android
or npm run start:ios
to run the application.
==== Running Tests
. Run npm test
to execute all unit tests and check code coverage thresholds.
. View code coverage in the local coverage/
directory.
=== Contributing
Please label branches using the following format:
<full name>/AT-<issue number>/<feature name>
Please write commit messages using the following format:
AT-<issue number> <commit message>
``