Skip to main content

Android Emulator Setup for Salesforce

Setting up android emulator for salesforce

Pre-requisites:

  1. SFDX CLI
  2. VS code with Salesforce & SFDX extensions

Step1: Install/update required SFDX plugins.

  • sfdx plugins:install @salesforce/lwc-dev-server
  • sfdx plugins:install @salesforce/lwc-dev-mobile
  • sfdx plugins:update

Step2: Download & Install Android Studio.

Step3: Additional downloads to complete Android Studio setup.

  1. Android Studio | Configure | SDK Manager: download at least one SDK Platform from API levels 23 through 29 (install at least latest 3 version or as per requirement)
    Android Studio SDK Manager

  2. Android Studio | Configure | AVD Manager: download at least 1 system image that supports API 29 and Google APIs (create a dummy virtual device to get to Images screen)
    • Click the ‘Create Virtual Device’ button
      Android Studio AVD Manager

    • Choose any existing device with Google Play icon.
      Android Studio - Device Selector

    • Move to 'x86 Images' tab and download both images (Google Play & Google APIs) with API:29 and ABI:x86_64
      Android Studio - System Image Selector

  3. Create a Virtual Device:
    • Can choose an existing device
      Android Studio - Device Selector
    • or create a New Hardware profile (using specs and skin from web)
      Android Studio - Hardware Profile Configuration
    • Select one of the previously downloaded ’x86 Images’ in the next menu.
      Android Studio - System Image Selector
    • Choose an AVD name and finish set-up
      Android Studio - Virtual Device Configuration

Step4: Set up 'Environment Variables'.

  1. ANDROID_HOME = C:\Users\<user>\AppData\Local\Android\Sdk
  2. JAVA_HOME = C:\Program Files\Android\Android Studio\jre

Step5: Validate Setup correct-ness.

  • sfdx force:lightning:local:setup -p android

Step6: Using AVDs for testing.

  1. Specific component testing (launched in android device's default browser)
    • Start a Local LWC server: sfdx force:lightning:lwc:start
    • Preview component in emulated device: - sfdx force:lightning:lwc:preview -p android -n component_name [-t target_AVD_name]
  2. Test using Salesforce App.
    • Install Salesforce App on the AVD from play-store (may need to enable play-store first, if using a google_api image as per step#3)

      Open AVD on disk and update below lines in the 'config' file to enable playstore.


      1. PlayStore.enabled=false to PlayStore.enabled=true
      2. image.sysdir.1=system-images\android-29\google_apis\x86_64\ to image.sysdir.1=system-images\android-29\google_apis_playstore\x86_64\
      3. tag.id=google_apis to tag.id=google_apis_playstore
    • Launch and log-in SF app with environment specific credential.
    • Check desired Functionality.

Comments

Popular posts from this blog

Few Basic & Advanced Git Commands: Possibly necessary, Definitely helpful

Python: Quick Revision