Skip to content

Setup your project

SimCoder edited this page Nov 18, 2021 · 1 revision

Android studio initialization

  1. Open android studio and click on Open an existing Android Studio Project Make sure you open the android folder and not the whole folder you unzipped. When opening the project a error will appear after compiling, do not worry, the next steps will fix that.
  2. Now you are inside the project in android studio, the next thing we must do is change the package name of our project:
  3. Make sure on the project tab the option Android is selected.
  4. On the settings button (the cog on the top right corner) unselect Compact middle packages.
  5. Open app -> java -> com -> simcoder -> uber and right click both simcoder and uber to change the name of both of them, check the image bellow to see how it is done. They must be different from the default one.
  6. Go to the file build.gradle (module: app) at Gradle Scripts -> build.gradle(module:app) and change the name of the applicationId to match the name of the previous step.

Setup Stripe

Note - If you do not want to enable stripe and choose to use the app as a cash only payment option, you may skip this part.

  1. Go to https://dashboard.stripe.com/register and create a stripe account, if you already have one you can just login to that account.
  2. Enable test Data which is on the left pane on your stripe dashboard.
  3. Go to connect accounts page -> click complete your platform profile -> start then steps in this page that will appear, and choose the following options (The gold rule is choose which options gives lyft as an example):
    • Set up recommended integration: i. Developer integration ii. Accept payments and pay sellers.... iii. subscriptions, plans,.... iv. Use a prebuilt checkout form
    • Activate your stripe account - Just do what it asks for.
    • Get your test API keys - Save the test keys. (publishable key and secret key)
  4. Go to Connect and make sure it is active, if it is data on connected account, payments,... will appear.
  5. Open the android studio and go to app -> res -> values -> strings.xml and paste the following keys:

Setup Firebase

  1. Go to android studio and click on Tools -> Firebase, a pane will appear on right side.
  2. Click on Authentication -> Email and Password authentication -> Connect to firebase
  3. Choose Create new Firebase project, choose a region of your choosing and click Connect to Firebase.
  4. Go to your preferred web browser and go to www.firebase.com -> go to dashboard and enter pn the project you've just created, after that do the following:
    • Go to the Authentication page:
    • Enter Sign-In Method. 2. Select and activate: 1. Email and password 2. Google
    • Go to the Database page:
      • Create Realtime Database
      • Start in test mode
      • Go to the rules and copy the contents of the file realtime_database_rules.json that is in the root folder of the project and paste them in the rules
    • Go to the Storage Page:
      • Click on get started.
      • Next
      • Choose a location and click Done
      • Upgrade your payment plan to Blaze

Setup OneSignal

  1. Go to www.onesignal.com and create an account.
  2. Create a new Application
  3. On Pop up that appears do the following: a. Select Google Android.
    • Go to the firebase dashboard -> Click on the settings (cog on the left pane) -> project settings -> Cloud Messaging. Get both the Server Key and SenderID, then paste them into the onesignal corresponding. inputs
    • Select Native Android
    • Copy the AppId that shows up.
    • Open you android studio project and go to the build.gradle file we went to in order to set the applicationId in the beginning, and past the oneSignal AppId in the field that says INSERT_ONE_SIGNAL_KEY

Firebase Functions

  1. Install nodejs which you can find at https://nodejs.org/en/, you can skip this step if you already have it installed
  2. Install firebase tools, by running the following command on your terminal > npm install -g firebase-tools
  3. Open the firebase_functions folder on your terminal by cd to it.
  4. Copy the files in the folder to another place on your pc.
  5. Login to your firebase account by running the following command: > firebase login
  6. initialize the setup project with: > firebase init
  7. Enter the following options into the terminal:
    • ? Are you ready to proceed? Y
    • ? Which Firebase CLI features do you want to set up for this folder? Press Space - select features, then Enter to confirm your choices. **Functions/Hosting.*
    • ? Please select an option: Use an existing project-> choose your project
    • ? What language would you like to use to write Cloud Functions? Javascript
    • ? Do you want to install dependencies with npm now? Y
    • ? What do you want to use as your public directory? public
    • ? Configure as a single-page app (rewrite all urls to /index.html)? N
    • ? Do you want to use ESLint to catch probable bugs and enforce style? **Y**
  8. go to functions > cd functions and install: 1. stripe: > npm i stripe 2. geofire: > npm i geofire
  9. with the 3 files you copied in the beginning of the firebase functions setup: a. replace index.js inside the functions folder. b. replace the firebase file inside the root of firebase_functions c. replace the index.html inside the public folder
  10. With the stripe secret key (Or a random string like 'placeholder' if you don't want to enable stripe) run the following command in the terminal: > firebase functions:config:set stripe.sk=
  11. With the stripe publishable key (Or a random string like 'placeholder' if you don't want to enable stripe) run the following command in the terminal: > firebase functions:config:set stripe.pk=
  12. Deply the project: > firebase deploy
  13. Go to the firebase dashboard -> functions and there should be a list of all the functions we've just uploaded. grab the url in the payout function and grab the url without the word payout at the end, this will be our base url
  14. open android studio and go to app -> res -> values -> strings.xml and add the following strings:
    • paste your base url there where it says INSERT_FIREBASE_BASE_URL. It should look something like https://xx-yyyy-zzzzzz.cloudfunctions.net/ (Do not forget the forward slash at the end)
    • In the firebase dashboard go to hosting and copy the Domain url which should look like https://xxxxxxxx.web.app then paste it in INSERT_FIREBASE_HOSTING_URL
    • (Skip if you don't want to enable stripe) In the stripe link where you got the INSERT_STRIPE_CLIENT_ID ( https://dashboard.stripe.com/settings/applications ) add the Domain url to the redirect list.
    • (Skip if you don't want to enable stripe) go to the following page https://dashboard.stripe.com/test/webhooks and on the "endpoints receiving events from account add the endpoints "firebase_functions_url/webhook" and select every option with setup_intent.

Google maps

  1. Go to google api console at https://console.developers.google.com/apis
  2. Click Enable Apis and service
  3. Enable the following:
    • Directions API
    • Places API
    • Maps SDK for android
  4. Go to credentials and copy the Android Key then in the strings.xml file paste it at INSERT_GOOGLE_MAPS_KEY.
  5. Enable billing for your project, otherwise it may not work.

Done!

You can now deploy the android project to your android device and test it. If you have any questions please use the issues of this repo.