Fakultas Ilmu Komputer UI

README.md 5.17 KB
Newer Older
1
2
# **TBCare - Mobile**
The repository for TBCare mobile codebase
3
## **Table of Contents**
4
5
6
7
- [Status](#status)
- [Prerequisites](#prerequisites)
- [Usage](#usage)
    - [Notable](#notable)
8
9
10
    - [Setup](#setup)
        - [Smartphone setup](#smartphone-setup)
        - [Emulator setup](#emulator-setup)
Nandhika Prayoga's avatar
Nandhika Prayoga committed
11
    - [Commands](#commands)
12
- [Troubleshooting](#troubleshooting)
13
- [Maintainers](#maintainers)
14
15

## **Status**
16
17
18
19
20
21
-  Staging

    [![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/ppti-mobile-apps-monitoring-wabah-tuberkolosis/neza-mobile/badges/staging/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/ppti-mobile-apps-monitoring-wabah-tuberkolosis/neza-mobile/commits/staging)

- Production

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    [![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/ppti-mobile-apps-monitoring-wabah-tuberkolosis/neza-mobile/badges/master/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/ppti-mobile-apps-monitoring-wabah-tuberkolosis/neza-mobile/commits/master)

## **Prerequisites**
Install the following packages/tools:
- Android Studio (Optional)
- Android SDK
    - Platforms **v28**
    - Tool
    - Build-tools **v28.0.3**
- JDK 8
- node **v12.14.0**
- npm **v6.13.6+**
- npx **v6.13.6+**

Create **.env** file in the root project and fill the file with the following format:
```bash
38
39
API_MAIN_URL=http://localhost:8000  # Make sure no '/' is appended at the end
GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID located in the environment variables of the repository>
40
41
``` 

42
43
44
45
46
Install all dependencies by run this command in the root of project
```bash
npm i
```

47
## **Usage**
48
49
50
51
52
53
54
55
56
* ### **Notable**
    1. Don't use an emulator and your smartphone simultaneously or using many emulator is also not allowed. Make sure there is **only 1 available device** by checking the number of connected devices by this command:
        ```bash
        adb devices
        ```
* ### **Setup**
    Choose one of these two ways to run the application
    * #### **Smartphone setup**
        Ensure that you have enabled **USB debugging** on you phone settings. If you have problem to do that, try [this](https://www.google.com/search?q=how+to+enable+usb+debugging+on+my+awesome+smartphone&oq=how+to+enable+usb+debugging+on+my+awesome+smartphone&aqs=chrome..69i57.14114j0j7&sourceid=chrome&ie=UTF-8).
57

58
    * #### **Emulator setup**
59
60
        Ensure that you have create you own emulator with **maximum API level is 25** in android studio. Then, run your emulator from android studio 
        * Until this point, the previous dev team has found no way to run the code in WSL with the emulator outside of WSL, thus all development is done outside of WSL
61

Nandhika Prayoga's avatar
Nandhika Prayoga committed
62
63
### **Commands**
Assume you have setted up everything.
64
* #### Run android
65
66
67
    * for debug version
    ```
    npx react-native run-android --variant=debug
68
    ```
69
70
71
    * for release version
    ```
    npx react-native run-android --variant=release
72
73
    ```
* #### Run ios
74
75
76
77
78
    * for debug version
    ```
    npx react-native run-ios --variant=debug
    ```
    * for release version
79
    ```
80
    npx react-native run-ios --variant=release
81
    ```
Nandhika Prayoga's avatar
Nandhika Prayoga committed
82
83
84
85
86
* #### Build APK locally
    ```
    cd android
    gradlew assembleRelease || ./gradlew assembleRelease
    ```
87

Nandhika Prayoga's avatar
Nandhika Prayoga committed
88
## **Troubleshootings**
89
* ### **Uncleaned gradlew**
90
    ```bash
91
92
    error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
    Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
93
    ```
94
    Go inside android directory and run this command
95
    ```bash
Nandhika Prayoga's avatar
Nandhika Prayoga committed
96
    gradlew clean || ./gradlew clean
97
98
99
100
    ```
* ### **Caching problem**
    Clear your cache by this command.
    #### **Windows**
101
    ```bash
102
    npm cache clean --force && npm install && npm start -- --reset-cache
103
    ```
104
    #### **Unix**
105
    ```bash
106
    watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache
Nandhika Prayoga's avatar
Nandhika Prayoga committed
107
108
    cd android
    ./gradlew clean
109
    ```
110
111
112
113
114
115
116
* ### **Corrupt modules**
    If clearing caches doesn't work or sometimes you face an error such as *"Cannot find module..."*. This could be due to a corrupt installation, then try to follow this procedure.
    1. Delete **node_modules** directory in the root project.
    2. Re-install all modules by command:
        ```
        npm i
        ```
117

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
* ### **Backend running in WSL**
    If the local backend server is running in WSL, run this command
    ```
    adb reverse tcp:8000 tcp:8000
    ```

* ### **Incorrect keystore**
    If the emulator previously was built using a the debug version, then attempted to build using the release version, or vice versa, run this command first then try again
    ```
    adb uninstall com.tbcare
    ```

* ### **Protected data**
    Protected data such as keystore passwords, google client id, etc. are saved in the environment variables of the repository. Ask a maintainer to view/edit them for CI/CD usage
    

134
135
136
## **Maintainers**
- Dave Nathanael
- Irwanto
137
- Jonathan Christopher Jakub
138
139
- Josh Sudung
- Nandhika Prayoga