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
-
Clone the repository:
git clone https://github.com/jfeinstein10/SlidingMenu.git -
Import the library into Eclipse:
- Go to
File > Import - Select
Android > Existing Android Code Into Workspace - Browse to the
SlidingMenu/librarydirectory - Click
Finish
- Go to
-
Clean the project to generate necessary binaries:
- Right-click the library project
- Select
Project > Clean
Option 2: Using Android Studio
-
Clone the repository:
git clone https://github.com/jfeinstein10/SlidingMenu.git -
Import the library:
- Open Android Studio
- Select
File > New > Import Module - Browse to the
SlidingMenu/librarydirectory - Click
Finish
-
Add the library as a dependency to your project:
- Open your app's
build.gradlefile - Add the following line to
dependencies:implementation project(':library')
- Open your app's
Configuration
For Eclipse Users
- Add SlidingMenu as a dependency to your existing project:
- Right-click your project
- Select
Properties > Android - Under
Library, clickAdd - Select the SlidingMenu library
For Android Studio Users
-
Ensure the library is properly referenced in your
settings.gradle:include ':app', ':library' -
Sync your project with Gradle files.
Optional: ActionBarSherlock Integration
If you want to use ActionBarSherlock with SlidingMenu:
- Clone and import ActionBarSherlock into your workspace
- Add ActionBarSherlock as a dependency to SlidingMenu
- Modify your activities to extend
Sherlock___Activityinstead of___Activity
Build & Run
Local Development
-
Eclipse:
- Clean and build your project
- Run on an emulator or connected device
-
Android Studio:
- Click
Build > Make Project - Run on an emulator or connected device using the green play button
- Click
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:
-
Building your APK:
- Eclipse:
Project > Export > Android Application - Android Studio:
Build > Generate Signed Bundle / APK
- Eclipse:
-
Testing on Devices:
- Connect physical devices via USB
- Use Android Debug Bridge (ADB):
adb install app.apk
-
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
-
R.java not generated:
- Cause: Project not cleaned after import
- Solution: Right-click project →
Project > Clean
-
Dependency errors in Android Studio:
- Cause: Gradle sync issues
- Solution: Click
Sync Project with Gradle Files
-
SlidingMenu not displaying:
- Cause: Incorrect mode or touch settings
- Solution: Verify
setMode()andsetTouchModeAbove()values
-
Shadow not appearing:
- Cause: Missing shadow drawable resource
- Solution: Ensure
setShadowDrawable()references a valid drawable
-
Behind view width issues:
- Cause: Using both
behindOffsetandbehindWidthin XML - Solution: Use only one of these attributes
- Cause: Using both
-
ActionBarSherlock integration problems:
- Cause: Activities not extending Sherlock variants
- Solution: Change
ActivitytoSherlockActivityin your activity classes
Debug Tips
- Enable logging in
CustomViewAbove.javaby settingDEBUG = true - Check logcat for runtime errors
- Verify all resource references (drawables, layouts, dimensions) exist
Performance Considerations
- Use
TOUCHMODE_MARGINfor 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