Skip to main content

Prerequisites

Before you begin, ensure you have the following installed:

Android Studio

Version 3.1.4 or higher

Java Development Kit

JDK 8 or higher

Android SDK

API Level 22 (Lollipop) minimum

Firebase Account

Free tier is sufficient

Step 1: Install Android Studio

1

Download Android Studio

Download Android Studio from the official website.
The Sales Management App uses Android Studio 3.1.4 with Gradle 3.1.4. Newer versions should work but may require dependency updates.
2

Install SDK Components

Launch Android Studio and install the following SDK components:
  • Android SDK Platform 26 (Oreo)
  • Android SDK Build-Tools 27.0.3
  • Android Support Repository
  • Google Repository
Navigate to Tools > SDK Manager to install these components.
3

Configure SDK Path

Verify your SDK path is correctly set:
# Linux/Mac
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

# Windows
setx ANDROID_HOME "%USERPROFILE%\AppData\Local\Android\Sdk"

Step 2: Configure Gradle Dependencies

The project uses specific Gradle configurations. Here’s the complete setup:

Project-Level build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
}
The project uses compile instead of implementation for some dependencies. While deprecated, this is intentional for compatibility with the project’s Gradle version.

Key Dependencies Explained

  • firebase-core: Analytics and core Firebase functionality
  • firebase-database: Real-time database for chat, inventory, and user data
  • firebase-storage: Cloud storage for profile images and attachments
  • firebase-auth: Email/password authentication
  • firebase-ui-storage: UI components for Firebase Storage
Powerful charting library used for:
  • Line graphs showing salesperson progress over time
  • Pie charts for manager profit analysis
  • Customizable chart styling and animations
Image loading and caching library with automatic:
  • Image compression before Firebase upload
  • Memory and disk caching
  • Placeholder and error image handling
Custom ListView implementation enabling swipe gestures for:
  • Deleting inventory items
  • Managing chat conversations
  • Quick actions on list items

Step 3: Firebase Configuration

Firebase powers authentication, database, and storage. Follow these steps to set up your Firebase project:
1

Create Firebase Project

  1. Go to Firebase Console
  2. Click Add Project
  3. Enter project name (e.g., “sales-management-app”)
  4. Accept terms and click Create Project
2

Add Android App

In your Firebase project:
  1. Click the Android icon to add an Android app
  2. Enter package name: project.avishkar.salesmanagement
  3. (Optional) Add app nickname: “Sales Management”
  4. Click Register App
The package name must match exactly as defined in app/build.gradle’s applicationId.
3

Download google-services.json

  1. Download the google-services.json file
  2. Place it in your project’s app/ directory:
your-project/
├── app/
   ├── google-services.json  # Place here
   ├── build.gradle
   └── src/
├── build.gradle
└── settings.gradle
Never commit google-services.json to version control if it contains production credentials. Use different files for development and production.
4

Enable Authentication

In Firebase Console, navigate to Authentication > Sign-in method:
  1. Click Email/Password
  2. Enable both toggles:
    • Email/Password
    • Email link (passwordless sign-in)
  3. Click Save
MainActivity.java:126
// The app uses Firebase Authentication
auth.signInWithEmailAndPassword(email, password)
    .addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if (task.isSuccessful()) {
                // Authentication successful
            }
        }
    });
5

Set Up Realtime Database

Navigate to Database > Realtime Database:
  1. Click Create Database
  2. Choose location (e.g., us-central1)
  3. Start in Test Mode for development
  4. Click Enable
The app expects this database structure:
{
  "Manager": {
    "userId1": {
      "email": "[email protected]",
      "name": "John Manager",
      "phone": "+1234567890"
    }
  },
  "Salesperson": {
    "userId2": {
      "emailId": "[email protected]",
      "name": "Jane Sales",
      "phone": "+0987654321"
    }
  },
  "Inventory": {
    "itemId1": {
      "itemName": "Product A",
      "total_available": 100,
      "sold": 25,
      "profit": 75
    }
  }
}
6

Configure Firebase Storage

Navigate to Storage:
  1. Click Get Started
  2. Use default security rules for development
  3. Click Done
The app uses this storage structure:
Constants.java:4
public static final String STORAGE_PATH_UPLOADS = "uploads/";
public static final String DATABASE_UPLOADS = "uploads";
Profile images and attachments are stored in the uploads/ directory.

Step 4: Repository Setup

The project requires JitPack and Maven Central for third-party libraries:
repositories {
    maven { url "https://jitpack.io" }
    mavenCentral()
    google()
    jcenter()
}
If you encounter build errors, try:
  1. File > Invalidate Caches / Restart
  2. Run ./gradlew clean from terminal
  3. Sync Gradle files again

Step 5: Verify Installation

Run these commands to verify everything is set up correctly:
# Check Gradle wrapper
./gradlew --version

# Build the project
./gradlew build

# List available tasks
./gradlew tasks

# Run tests
./gradlew test
Expected output:
> Task :app:compileDebugJavaWithJavac
> Task :app:mergeDebugResources
> Task :app:processDebugManifest

BUILD SUCCESSFUL in 45s

Troubleshooting

Problem: “Failed to resolve: com.google.firebase:firebase-core:16.0.1”Solution:
# Add Google Maven repository
# In build.gradle (Project)
allprojects {
    repositories {
        google()  # Must be first
        jcenter()
    }
}
Problem: “File google-services.json is missing”Solution:
  1. Ensure file is in app/ directory (not root)
  2. Check filename is exactly google-services.json
  3. Verify package name matches Firebase configuration
Problem: “Failed to find Build Tools revision 27.0.3”Solution:
# Install via SDK Manager or command line
sdkmanager "build-tools;27.0.3"
Problem: Device API level too lowSolution: The app requires API 22 (Android 5.1) minimum. Use an emulator or device with Android 5.1 or higher.

Next Steps

Quick Start Guide

Now that your environment is configured, learn how to clone the repository and run the app for the first time.

Build docs developers (and LLMs) love