A comprehensive Android application for testing and development purposes that allows setting custom GPS locations.
- Custom Location Setting: Set any latitude and longitude as your device location
- Material Design UI: Modern and intuitive user interface with Material Components
- Permission Management: Automatic handling of location permissions
- Mock Location Provider: Works with both GPS and Network providers
- Input Validation: Validates coordinate ranges before setting location
- API Compatibility: Supports Android API 23+ (Android 6.0 Marshmallow and above)
- Error Handling: Comprehensive error handling and user feedback
- Android Studio Arctic Fox or later
- Android SDK 34
- Gradle 8.0+
- Kotlin 1.9+
- Minimum Android API 23 (Android 6.0)
- Target Android API 34 (Android 14)
- Go to Settings → About Phone
- Tap Build Number 7 times
- Developer Options will be enabled
- Go to Settings → Developer Options
- Find Select mock location app
- Choose Mock Location from the list
The app will automatically request the following permissions:
ACCESS_FINE_LOCATIONACCESS_COARSE_LOCATIONACCESS_MOCK_LOCATION(handled through Developer Options)
- Clone the repository:
git clone https://github.com/brutalharsh/mock-location-app.git
cd mock-location-app-
Open the project in Android Studio
-
Build the project:
- Click Build → Make Project
- Or use keyboard shortcut:
Ctrl+F9(Windows/Linux) orCmd+F9(Mac)
-
Run the app:
- Click Run → Run 'app'
- Or use keyboard shortcut:
Shift+F10(Windows/Linux) orCtrl+R(Mac)
- Download the latest APK from the releases section
- Enable Install from Unknown Sources in your device settings
- Install the APK file
-
Launch the App
- Open the Mock Location app from your app drawer
-
Enter Coordinates
- Latitude: Enter a value between -90 and 90
- Longitude: Enter a value between -180 and 180
- Default values are set to Google's headquarters (37.4220, -122.0841)
-
Set Location
- Tap the Set Location button
- The mock location will be applied immediately
-
Verify Location
- Open any map application (Google Maps, etc.)
- Your location should appear at the coordinates you set
MockLocationApp/
├── app/
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/com/example/mocklocation/
│ │ │ │ └── MainActivity.kt
│ │ │ ├── res/
│ │ │ │ ├── layout/
│ │ │ │ │ └── activity_main.xml
│ │ │ │ ├── values/
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ └── themes.xml
│ │ │ │ └── drawable/
│ │ │ └── AndroidManifest.xml
│ │ └── test/
│ └── build.gradle
├── gradle/
├── build.gradle
├── settings.gradle
└── README.md
- LocationManager: System service for managing location providers
- Test Provider: Simulates GPS/Network location providers
- FusedLocationProviderClient: Google Play Services location API
- Material Components: Modern UI elements with Material Design
checkLocationPermissions(): Verifies and requests necessary permissionscheckMockLocationEnabled(): Checks if app is selected as mock location providersetMockLocation(): Validates input and sets mock locationsetMockLocationForProvider(): Configures mock location for specific provider
The app handles different Android API levels:
- API 31+: Uses
ProviderPropertiesfor location provider configuration - API 23-30: Uses deprecated
Criteriaconstants for backward compatibility - API 26+: Enhanced location accuracy parameters
- Verify Developer Options are enabled
- Confirm app is selected as mock location app
- Check location permissions are granted
- Ensure location services are enabled on device
- Clear app data and cache
- Reinstall the application
- Check Android Studio logcat for error details
- Force stop other location-based apps
- Restart location services
- Reboot your device
# Clean build
./gradlew clean
# Build debug APK
./gradlew assembleDebug
# Build release APK
./gradlew assembleRelease
# Run tests
./gradlew testThe project follows Kotlin coding conventions:
- 4 spaces for indentation
- CamelCase for class names
- camelCase for function and variable names
- ALL_CAPS for constants
- AndroidX Core KTX: 1.12.0
- AppCompat: 1.6.1
- Material Components: 1.11.0
- ConstraintLayout: 2.1.4
- Play Services Location: 21.0.1
- JUnit: 4.13.2 (testing)
- Espresso: 3.5.1 (UI testing)
- This app requires mock location permissions which can only be granted through Developer Options
- Mock locations are only active while the app is running
- The app does not collect or transmit any location data
- All location data is processed locally on the device
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is for educational purposes. Please ensure you comply with your local laws and regulations when using mock location functionality.
This application is intended for development and testing purposes only. Users are responsible for ensuring their use of this app complies with all applicable laws and terms of service of other applications.
For issues, questions, or suggestions, please open an issue on GitHub.
- 1.0 (Current)
- Initial release
- Basic mock location functionality
- Material Design UI
- Support for Android 6.0+
- Location history/favorites
- Map integration for visual location selection
- Automated location paths/routes
- Widget for quick location switching
- Export/Import location profiles
- Background service for continuous mock location
- Speed and altitude customization
- Multiple coordinate format support