-
Notifications
You must be signed in to change notification settings - Fork 717
Setup your project
SimCoder edited this page Nov 18, 2021
·
1 revision
- 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.
- Now you are inside the project in android studio, the next thing we must do is change the package name of our project:
- Make sure on the project tab the option Android is selected.
- On the settings button (the cog on the top right corner) unselect Compact middle packages.
- 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.
- 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.
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.
- Go to https://dashboard.stripe.com/register and create a stripe account, if you already have one you can just login to that account.
- Enable test Data which is on the left pane on your stripe dashboard.
- 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)
- Set up recommended integration:
- Go to Connect and make sure it is active, if it is data on connected account, payments,... will appear.
- Open the android studio and go to app -> res -> values -> strings.xml and paste the following keys:
- Publishable key there where it says INSERT_STRIPE_PUBLISHABLE_KEY.
- Go to the following link and get the Test mode client ID then past it to INSERT_STRIPE_CLIENT_ID https://dashboard.stripe.com/settings/applications
- Go to android studio and click on Tools -> Firebase, a pane will appear on right side.
- Click on Authentication -> Email and Password authentication -> Connect to firebase
- Choose Create new Firebase project, choose a region of your choosing and click Connect to Firebase.
- 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
- Go to www.onesignal.com and create an account.
- Create a new Application
- 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
- Install nodejs which you can find at https://nodejs.org/en/, you can skip this step if you already have it installed
- Install firebase tools, by running the following command on your terminal
> npm install -g firebase-tools
- Open the firebase_functions folder on your terminal by cd to it.
- Copy the files in the folder to another place on your pc.
- Login to your firebase account by running the following command:
> firebase login
- initialize the setup project with:
> firebase init
- 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**
- go to functions
> cd functions
and install: 1. stripe: > npm i stripe 2. geofire: > npm i geofire - 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
- 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=
- 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=
- Deply the project:
> firebase deploy
- 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
- 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.
- Go to google api console at https://console.developers.google.com/apis
- Click Enable Apis and service
- Enable the following:
- Directions API
- Places API
- Maps SDK for android
- Go to credentials and copy the Android Key then in the strings.xml file paste it at INSERT_GOOGLE_MAPS_KEY.
- Enable billing for your project, otherwise it may not work.
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.