{“content”:”---\nname: termux-api-gps-setup\ndescription: Set up Termux:API to access GPS, camera, clipboard and other Android features from Termux CLI\ntriggers:\n - “termux gps not working”\n - “termux-location not available”\n - “termux api setup”\n - “android gps from termux”\n---\n\n# Termux:API GPS Setup\n\n## Architecture (Important)\n\nTermux:API requires two components working together:\n1. CLI package (termux-api via pkg install termux-api) - the shell commands\n2. Android app (com.termux.api app) - the actual Android implementation\n\nBoth are REQUIRED. CLI alone does nothing without the app.\n\n## The Problem\n\nMany tutorials are outdated. Termux:API Android app was removed from Google Play. The error message:\n\nTermux:API is not yet available on Google Play\n\nis misleading — it means the Android app is missing OR that the app can’t communicate with Termux, NOT that it doesn’t exist.\n\nCritical insight: The error is embedded in the termux-api binary itself (NDK-compiled C code), not from any UI or package manager. Seeing it always means the Android app is either not installed OR can’t access Termux’s data directory.\n\n## Two-Component Architecture\n\n| Component | Installed by | Purpose |\n|-----------|-------------|---------|\n| CLI tools (termux-location, etc.) | pkg install termux-api | Shell commands in Termux |\n| Android app (com.termux.api) | F-Droid (separate install) | Actual Android service |\n\n**pkg install termux-api does NOT install the Android app.** They are separate. The CLI tools call the Android app via am startservice — if the app isn’t there or can’t be reached, you get the “Google Play” error.\n\n## Termux Source Mismatch = Broken (Important!)\n\nGoogle Play Termux + F-Droid Termux:API = guaranteed failure. Due to Android’s scoped storage / app sandboxing, apps from different sources cannot share /data/data/ directories. Even if both are installed, the API calls fail silently.\n\nSolution: Use the same source for both:\n- F-Droid Termux + F-Droid Termux:API ✅ (recommended)\n- Google Play Termux + Google Play Termux:API (if available) ✅\n\n## Installation Steps\n\n### 1. Install F-Droid (if not already)\n- Download from https://f-droid.org\n- F-Droid is an open-source app store for Android\n\n### 2. Install Termux:API Android app via F-Droid\n- Open F-Droid → Wait for repository refresh (bottom progress bar)\n- Search Termux:API\n- Install the app (blue/green Termux icon)\n- ⚠️ Do NOT install from Google Play (outdated/removed)\n\n### 3. Grant permissions\nbash\ntermux-setup-storage # also grants other permissions needed by API\n\n\n### 4. Verify\nbash\ntermux-location -p gps -r once\n\n\n## Key Commands (all available after installing termux-api package)\n\n| Command | Function |\n|---------|----------|\n| termux-location -p gps -r once | Get GPS once |\n| termux-location -p network -r once | Network-based location |\n| termux-battery-status | Battery info |\n| termux-camera-info | List cameras |\n| termux-camera-photo <path> | Take photo |\n| termux-clipboard-get | Read clipboard |\n| termux-clipboard-set <text> | Write clipboard |\n| termux-notification -t title -c content | Show notification |\n| termux-sms-inbox | List SMS |\n| termux-telephony-call <number> | Make call |\n| termux-sensor -s accelerometer | Read sensor |\n\n## Fallback: Python GPS (No Termux:API Needed)\n\nIf Termux:API won’t work due to source incompatibility, use Python instead:\n\nbash\npip install geocoder\npython -c \"import geocoder; g = geocoder.ip('me'); print(g.latlng)\"\n\n\nPrecision: city-level only (IP-based). For precise GPS, fix the Termux:API setup instead.\n\n## Common Issues\n\n- “Google Play” error + app IS installed: Termux and Termux:API are from different sources (e.g. GP Termux + F-Droid API) → scoped storage blocks communication → use same source for both\n- “Google Play” error + app NOT installed: Android app missing → install via F-Droid\n- Permission denied: Run termux-setup-storage first\n- GPS returns null: Check location permission in Android Settings → Apps → Termux:API → Permissions\n- CLI works but app missing: Verify app installed at /data/data/com.termux/api/ (Android app data dir) — if this dir doesn’t exist, the Android app is not actually installed despite CLI being present\n\n## Note on Termux Version Compatibility\n\nIf using Google Play Termux, consider switching to F-Droid Termux for full compatibility with F-Droid Termux:API app. Google Play version may be outdated.\n”}