← Back to jfeinstein10/SlidingMenu

How to Deploy & Use jfeinstein10/SlidingMenu

SlidingMenu - Android Library Deployment Guide

Prerequisites

  • Android Studio or Eclipse with Android Development Tools (ADT)
  • Android SDK with API level 8 or higher
  • Java Development Kit (JDK) version 6 or higher

Installation

Option 1: Using Eclipse

  1. Clone the repository:

    git clone https://github.com/jfeinstein10/SlidingMenu.git
    
  2. Import the library into Eclipse:

    • Go to File > Import
    • Select Android > Existing Android Code Into Workspace
    • Browse to the SlidingMenu/library directory
    • Click Finish
  3. Clean the project to generate necessary binaries:

    • Right-click the library project
    • Select Project > Clean

Option 2: Using Android Studio

  1. Clone the repository:

    git clone https://github.com/jfeinstein10/SlidingMenu.git
    
  2. Import the library:

    • Open Android Studio
    • Select File > New > Import Module
    • Browse to the SlidingMenu/library directory
    • Click Finish
  3. Add the library as a dependency to your project:

    • Open your app's build.gradle file
    • Add the following line to dependencies:
      implementation project(':library')
      

Configuration

For Eclipse Users

  1. Add SlidingMenu as a dependency to your existing project:
    • Right-click your project
    • Select Properties > Android
    • Under Library, click Add
    • Select the SlidingMenu library

For Android Studio Users

  1. Ensure the library is properly referenced in your settings.gradle:

    include ':app', ':library'
    
  2. Sync your project with Gradle files.

Optional: ActionBarSherlock Integration

If you want to use ActionBarSherlock with SlidingMenu:

  1. Clone and import ActionBarSherlock into your workspace
  2. Add ActionBarSherlock as a dependency to SlidingMenu
  3. Modify your activities to extend Sherlock___Activity instead of ___Activity

Build & Run

Local Development

  1. Eclipse:

    • Clean and build your project
    • Run on an emulator or connected device
  2. Android Studio:

    • Click Build > Make Project
    • Run on an emulator or connected device using the green play button

Example Usage

public class SlidingExample extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(R.string.attach);
        setContentView(R.layout.content);
        
        // Configure the SlidingMenu
        SlidingMenu menu = new SlidingMenu(this);
        menu.setMode(SlidingMenu.LEFT);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        menu.setShadowWidthRes(R.dimen.shadow_width);
        menu.setShadowDrawable(R.drawable.shadow);
        menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
        menu.setFadeDegree(0.35f);
        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        menu.setMenu(R.layout.menu);
    }
}

Deployment

Publishing Your App

Since SlidingMenu is an Android library, deployment involves:

  1. Building your APK:

    • Eclipse: Project > Export > Android Application
    • Android Studio: Build > Generate Signed Bundle / APK
  2. Testing on Devices:

    • Connect physical devices via USB
    • Use Android Debug Bridge (ADB):
      adb install app.apk
      
  3. Publishing to Google Play Store:

    • Create a developer account on Google Play Console
    • Upload your APK
    • Complete store listing and publish

Alternative Distribution

  • GitHub Releases: Share APKs through GitHub releases
  • Third-party App Stores: Upload to Amazon Appstore, APKPure, etc.

Troubleshooting

Common Issues and Solutions

  1. R.java not generated:

    • Cause: Project not cleaned after import
    • Solution: Right-click project → Project > Clean
  2. Dependency errors in Android Studio:

    • Cause: Gradle sync issues
    • Solution: Click Sync Project with Gradle Files
  3. SlidingMenu not displaying:

    • Cause: Incorrect mode or touch settings
    • Solution: Verify setMode() and setTouchModeAbove() values
  4. Shadow not appearing:

    • Cause: Missing shadow drawable resource
    • Solution: Ensure setShadowDrawable() references a valid drawable
  5. Behind view width issues:

    • Cause: Using both behindOffset and behindWidth in XML
    • Solution: Use only one of these attributes
  6. ActionBarSherlock integration problems:

    • Cause: Activities not extending Sherlock variants
    • Solution: Change Activity to SherlockActivity in your activity classes

Debug Tips

  • Enable logging in CustomViewAbove.java by setting DEBUG = true
  • Check logcat for runtime errors
  • Verify all resource references (drawables, layouts, dimensions) exist

Performance Considerations

  • Use TOUCHMODE_MARGIN for better performance on older devices
  • Avoid complex layouts in the behind view to maintain smooth sliding animations
  • Test on multiple screen densities to ensure proper sizing