This project is a mobile application to be used by traders that interact with farmers to collect agricultural goods.
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 passing the USB device through to VirtualBox first. |
-
Install Docker using the instructions on the 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.
-
Identify the path to your phone. This can be done using
lsusb
. For example the output could be:user@user-pc ~/boresha/agritrader $ lsusb Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 003: ID 093a:2521 Pixart Imaging, Inc. Optical Mouse Bus 003 Device 002: ID 0534:0002 Motorola, Inc. Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 055: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP) Bus 001 Device 002: ID 046d:0a03 Logitech, Inc. Logitech USB Microphone Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The path would then be
/dev/bus/usb/001/055
for the Samsung device (phone). -
Check that the Docker image can find your phone using
./dockerize.sh adb-devices /path/to/device/
. The output should include a device.user@user-pc ~/boresha/agritrader $ ./dockerize.sh adb /dev/bus/usb/001/055 List of devices attached * daemon not running. starting it now at tcp:5037 * * daemon started successfully * ce12160cdb9b2f1905 device
-
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.
-
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 togradle.properties
.gradle.properties
is the file that will actually be used. Fill in theAGRITRADER_DEPLOY_UNSTABLE_STORE_PASSWORD
andAGRITRADER_DEPLOY_UNSTABLE_KEY_PASSWORD
fields with the password. Ask someone for the password, it is not version controlled.ImportantBe very careful not to commit the passwords to version control. -
Ask for the
agritrader-deploy-unstable.keystore
keystore and copy it to theandroid/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
.
Follow steps found in the Building Projects with Native Code
tab in the React Native documentation for Getting Started for installing dependencies and setting up the mobile development environment, such as the Android SDK and build tools.
To try running the code on a device, follow the steps found in the React Native documentation for Running your app on a Device.
-
Make sure the
JAVA_HOME
andANDROID_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 thePATH
environment variables. The platform tools directory can be found inD:\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.
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
ornpm run start:ios
to run the application.