Smoothex / cloud-based-traffic-light-assistant

0 stars 0 forks source link

Android App APK Build

Welcome to our Cloud-based traffic light assistant app 👋

This is an Expo project created with create-expo-app.

Prerequisites

Changes in libraries

  1. react-native-google-places-autocomplete
    • Go to node_modules and find the library
    • In GooglePlacesAutocomplete.js go to line 866 and add the following code:
      if (stateText?.length > 0) {
      _handleChangeText(stateText);
      }
    • This allows for results to be queried when text is input by voice

How to build the app using EAS CLI

  1. In the terminal install eas-cli using npm install -g eas-cli
  2. Create an account for Expo Dev
  3. Log in with your credentials using eas login
  4. Configure your project using eas build:configure, which creates an eas.json file with configs
  5. Either build the android folder locally with npx expo prebuild or skip this step because it happens automatically in the pipeline
  6. Add the environmental variables from your .env file in Secrets of your Expo project on the Expo dev page in order to build the app correctly
  7. Start a building pipeline with eas build -p android --profile development
  8. After the pipeline succeeds you can download the .apk on your file via the link from your terminal or you can find it in Builds on the Expo dev page
  9. After installing the app on your physical device you have to start a server with npx expo start

How to run the app using Expo Go

  1. Install Expo Go on your physical device from Google Play for Android or App Store for iOS.

  2. Install dependencies by running npm install in the terminal.

  3. Set the EXPO_PUBLIC_GOOGLE_API_KEY environment in a .env file. This project uses Google APIs, so you need to configure an API Key in your Google Cloud account.

  4. Run npm start to start the app.

  5. On your device, open Expo Go and scan the QR code to connect to the development server. When the project starts loading, you see this in the terminal, see the gif below.

    demo-ezgif com-video-to-gif-converter

Build

Using GitHub Actions we have created a workflow for building an APK app for Android. It uses Expo Application Services (EAS) and specifically EAS Build, which builds the app binary for the project.

The build command starts the build process on the EAS Build servers by default. Since EAS is a paid service, the free tier is restricted to 30 builds per month. In order to avoid this limited number of builds, the eas build command in the pipeline uses the --local flag. This allows for running the same build process locally on the machine instead of in the Expo's managed environment. Although building locally has some limitations, the local builds do not count to the said free 30 builds per month.

Unfortunately, Expo secrets can only be accessed by EAS cloud builds, and the local builds inside the GitHub runners can't access the Google Geolocation API key we need for the maps. Therefore, we set the EXPO_PUBLIC_GOOGLE_API_KEY variable as a repository secret and include it in the workflow.