Skip to main content

Overview

This guide will walk you through cloning the repository, building the app, and logging in for the first time. By the end, you’ll have the app running on an Android device or emulator with a test user account.
Before starting, ensure you’ve completed the Installation guide with Android Studio and Firebase configured.

Step 1: Clone the Repository

1

Clone from GitHub

Open your terminal and run:
git clone https://github.com/gargmehul10/Sales-Management-App.git
cd Sales-Management-App
2

Verify Project Structure

Ensure the project structure looks like this:
Sales-Management-App/
├── app/
│   ├── build.gradle
│   ├── google-services.json  # Add your Firebase config here
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml
│           ├── java/
│           │   └── project/avishkar/salesmanagement/
│           │       ├── Registration/
│           │       │   ├── MainActivity.java
│           │       │   ├── SignUpSalesManager.java
│           │       │   └── SignUpSalesperson.java
│           │       ├── ManagerMain.java
│           │       ├── SalespersonMain.java
│           │       ├── Chat/
│           │       ├── Graph/
│           │       ├── Leaderboard/
│           │       └── InventoryItem.java
│           └── res/
├── build.gradle
├── settings.gradle
└── gradle.properties
3

Add Firebase Configuration

Copy your google-services.json file into the app/ directory:
cp ~/Downloads/google-services.json app/
The app will not build without a valid google-services.json file. See Firebase Configuration if you haven’t set this up yet.

Step 2: Build the Project

1

Open in Android Studio

  1. Launch Android Studio
  2. Click Open an Existing Project
  3. Navigate to the cloned directory and click OK
  4. Wait for Gradle sync to complete
2

Sync Gradle Files

If Gradle doesn’t sync automatically:
  1. Click File > Sync Project with Gradle Files
  2. Wait for dependencies to download (first time may take 5-10 minutes)
You should see output like:
Gradle sync finished in 1m 23s
3

Build the Application

Build the app to verify everything works:
# From terminal
./gradlew assembleDebug

# Or in Android Studio
# Build > Make Project (Ctrl+F9)
Expected output:
> Task :app:compileDebugJavaWithJavac
> Task :app:mergeDebugResources
> Task :app:processDebugGoogleServices
> Task :app:packageDebug

BUILD SUCCESSFUL in 1m 45s
47 tasks executed

Step 3: Set Up an Emulator or Device

You can run the app on an Android emulator or physical device:
1

Create a Virtual Device

  1. In Android Studio, click Tools > AVD Manager
  2. Click Create Virtual Device
  3. Select a device (e.g., Pixel 3)
  4. Choose a system image:
    • Recommended: Oreo (API 26) or higher
    • Minimum: Lollipop (API 22)
  5. Click Finish
2

Launch Emulator

In AVD Manager, click the play button next to your device.Wait for the emulator to boot completely (30-60 seconds).

Step 4: Run the Application

1

Deploy to Device

# Click the green play button in toolbar
# Or press Shift+F10
The app will install and launch automatically.
2

Verify Launch Screen

You should see the login screen with:
  • Email and password input fields
  • Radio buttons for Manager/Salesperson selection
  • Login button
  • “Sign up as a Manager” link
  • “Sign up as a Salesperson” link
Login Screen

Step 5: Create Your First Account

Let’s create a test Sales Manager account:
1

Navigate to Manager Sign Up

  1. On the login screen, tap “Sign up as a Manager”
  2. You’ll be taken to the Manager registration form
2

Fill Registration Form

Enter the following details:
  • Name: Test Manager
  • Email: [email protected]
  • Password: test1234 (minimum 6 characters)
  • Phone: +1234567890
  • Company: Test Company
Password must be at least 6 characters as enforced by Firebase Authentication:
MainActivity.java:133
if (password.length() < 6) {
    inputPassword.setError(getString(R.string.minimum_password));
}
3

Complete Registration

  1. Tap Sign Up
  2. Wait for Firebase to create the account (2-3 seconds)
  3. You’ll be automatically logged in and redirected to the Manager dashboard
4

Explore Manager Dashboard

You’re now in the Manager interface! You can:
  • My Team: View all salespersons (empty initially)
  • Inventory: Add and manage products
  • Chat: Access global chat room
  • Graphs: View profit analysis (requires inventory data)
  • Leaderboard: See top 10 salespersons
  • Profile: Update your account details

Step 6: Test Core Features

Let’s add some inventory to see the app in action:
1

Add Inventory Item

  1. Tap Inventory from the navigation menu
  2. Tap the + button (floating action button)
  3. Enter item details:
    • Name: Laptop
    • Total Available: 100
    • Sold: 25
    • Profit per unit: 200
  4. Tap Save
The inventory list will update with your new item:
InventoryItem.java:11
public InventoryItem(String itemName, int total_available, int sold, int profit) {
    this.itemName = itemName;
    this.total_available = total_available;
    this.sold = sold;
    this.profit = profit;
}
2

View in Firebase Console

Open your Firebase Console and navigate to Realtime Database:
{
  "Inventory": {
    "itemId_xyz": {
      "itemName": "Laptop",
      "total_available": 100,
      "sold": 25,
      "profit": 200
    }
  },
  "Manager": {
    "userId_abc": {
      "email": "[email protected]",
      "name": "Test Manager",
      "phone": "+1234567890"
    }
  }
}
All data syncs in real-time. Changes in Firebase Console appear instantly in the app, and vice versa.
3

Create a Salesperson Account

To test the full workflow:
  1. Log out from Manager account
  2. On login screen, tap “Sign up as a Salesperson”
  3. Register with different credentials:
  4. Explore the Salesperson dashboard
Salespersons can:
  • View inventory (read-only)
  • See their performance graphs
  • Check leaderboard ranking
  • Chat with the manager

Understanding User Roles

The app authenticates users and determines their role from Firebase:
if (RadioButtonSelect(radioGroup_type.getCheckedRadioButtonId()).equals("Manager")) {
    databaseRef = FirebaseDatabase.getInstance().getReference("Manager");
    databaseRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
            for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                SalesManager sm1 = snapshot.getValue(SalesManager.class);
                if (sm1.getEmail().equals(email)) {
                    SessionManager sm = new SessionManager(getApplicationContext());
                    sm.createLoginSession(snapshot.getKey(), "Manager");
                    goto_Manager();
                    break;
                }
            }
        }
    });
}
Users must select the correct role (Manager or Salesperson) that matches their registration. If a manager selects “Salesperson” during login, authentication will fail with:“This Email is not registered as Salesperson!!”

Next Steps

Chat Feature

Learn how to use the global chat room and personal messaging

Analytics & Graphs

Understand performance tracking and profit analysis

Inventory Management

Deep dive into adding, updating, and tracking inventory

API Reference

Explore the Java classes and Firebase structure

Troubleshooting

Problem: App crashes immediately after launchCommon causes:
  1. Missing or invalid google-services.json
  2. Firebase services not enabled
Solution:
# Check logcat for errors
adb logcat | grep -i firebase

# Look for:
# "Default FirebaseApp is not initialized"
# "google-services.json is missing"
Verify Firebase configuration in Installation Guide.
Problem: “Authentication failed” error on loginSolution:
  1. Verify Email/Password authentication is enabled in Firebase Console
  2. Check that password is at least 6 characters
  3. Ensure correct role is selected (Manager vs Salesperson)
  4. Verify internet connection (app requires network access)
Problem: Inventory or chat messages don’t show upSolution:
  1. Check Firebase Realtime Database rules:
    {
      "rules": {
        ".read": true,
        ".write": true
      }
    }
    
  2. Verify internet connectivity
  3. Check Firebase Console to see if data is being written
  4. Look for permission errors in logcat
Problem: Profile pictures or images don’t displaySolution:
  1. Verify Firebase Storage is set up and accessible
  2. Check storage rules allow read/write
  3. Grant storage permissions:
    AndroidManifest.xml:6
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
  4. Accept permission prompts when the app requests them
Having issues? Check the GitHub Issues or create a new issue with your error logs.

Build docs developers (and LLMs) love