← Back to googlesamples/android-UniversalMusicPlayer

How to Deploy & Use googlesamples/android-UniversalMusicPlayer

Universal Android Music Player (UAMP) Deployment Guide

Prerequisites

  • Android Studio 3.x or higher - Required for development and building the project
  • Android SDK - Included with Android Studio, ensure you have the latest SDK tools and platform tools
  • Java Development Kit (JDK) 8 or higher - Required for Android development
  • Physical Android device or emulator - For testing the application across different form factors

Installation

  1. Clone the repository:

    git clone https://github.com/android/uamp.git
    cd uamp
    
  2. Open in Android Studio:

    • Launch Android Studio
    • Select "Open an existing project"
    • Navigate to the cloned uamp directory and select it
  3. Sync Gradle:

    • Android Studio will automatically start syncing the Gradle files
    • Wait for the sync to complete and any necessary dependencies to download

Configuration

UAMP is a sample application and doesn't require external API keys or complex configuration. However, you may want to:

  1. Set up Android Emulator (if needed):

    • In Android Studio, go to Tools → AVD Manager
    • Create a new virtual device with different form factors (phone, tablet, TV) to test the multi-form factor support
  2. Enable USB Debugging (for physical devices):

    • On your Android device, go to Settings → About phone
    • Tap "Build number" 7 times to enable Developer options
    • Go to Settings → Developer options → Enable USB debugging

Build & Run

Running on a Device or Emulator

  1. Select a build variant:

    • In Android Studio, open the Build Variants tool window
    • Select the desired build variant (e.g., automotiveDebug for Android Automotive, mobileDebug for phones/tablets)
  2. Build and run:

    # From the command line
    ./gradlew assembleDebug
    ./gradlew installDebug
    

    Or use the Android Studio interface:

    • Click the green "Run" button or press Shift+F10
    • Select your target device or emulator
    • Wait for the app to build and install
  3. Alternative: Run from Android Studio:

    • Click the "Run" button (green triangle) in the toolbar
    • Select your target device from the device selector
    • The app will compile, install, and launch automatically

Testing Different Form Factors

UAMP supports multiple form factors. To test each:

  • Mobile/Tablet: Use a phone or tablet emulator/device
  • Android TV: Use a TV emulator or physical Android TV device
  • Android Auto: Use a compatible head unit or emulator (requires additional setup)
  • Android Wear: Use a Wear OS emulator or device
  • Google Cast: Use a Cast device or emulator (requires additional setup)

Deployment

Note: UAMP is a sample application and is no longer being maintained (as indicated by the deprecation warning). It is intended for learning and demonstration purposes rather than production deployment.

If you wish to distribute a modified version:

  1. Prepare for release:

    ./gradlew assembleRelease
    
  2. Sign the APK:

    • Create a signing key using Android Studio or the keytool command
    • Configure the signing settings in gradle.properties or local.properties
  3. Distribution options:

    • Google Play Store: Follow Google's app publishing guidelines
    • Direct APK distribution: Share the APK file directly with users
    • Enterprise deployment: Use Android Enterprise features for internal distribution

Troubleshooting

Common Issues and Solutions

  1. Build failures due to missing dependencies:

    • Ensure you have a stable internet connection for Gradle to download dependencies
    • Try "File → Invalidate Caches / Restart" in Android Studio
    • Clean and rebuild the project (Build → Clean Project, then Build → Rebuild Project)
  2. API level compatibility issues:

    • Check the compileSdkVersion, minSdkVersion, and targetSdkVersion in build.gradle files
    • Ensure your SDK manager has the required Android versions installed
  3. Emulator performance issues:

    • Enable hardware acceleration in your emulator settings
    • Use Android Studio's "Cold Boot Now" option to improve startup times
    • Consider using a physical device for better performance
  4. Media playback issues:

    • Check device permissions (storage, audio focus)
    • Verify that media files are accessible and not corrupted
    • Review the logcat output for specific media-related errors
  5. Multi-form factor display issues:

    • Test on actual devices when possible, as emulators may not perfectly replicate behavior
    • Check the layout files in res/layout* directories for form factor-specific adjustments

Getting Help

  • Official Documentation: Visit Android Developer Documentation
  • Stack Overflow: Search for issues tagged with android and media-player
  • GitHub Issues: While UAMP is deprecated, you can still browse existing issues for solutions
  • Android Community: Join Android developer communities and forums for support

Important Notes

  • UAMP is deprecated and no longer maintained, so some features may not work with the latest Android versions
  • For production applications, consider using the latest Android media APIs and following current best practices
  • The sample includes music from the Free Music Archive and sound libraries - ensure you comply with their licensing terms if redistributing

For more detailed information about UAMP's architecture and implementation, refer to the full guide included in the repository.