Last active
July 26, 2025 18:48
-
-
Save pablocattaneo/bce6998d0d3eba9c478f611da338d9ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## **How to Use AAPT to Check APK Permissions** | |
### **1. Build Your APK** | |
Make sure you have a built APK, for example: | |
``` | |
android/app/build/outputs/apk/release/app-release.apk | |
``` | |
### **2. Find Your AAPT Tool** | |
On macOS, with a typical Android Studio install, the path is: | |
``` | |
~/Library/Android/sdk/build-tools/<version>/aapt | |
``` | |
Replace `<version>` with your installed build tools version (e.g., `34.0.0`). | |
### **3. Run the Command** | |
Here’s the **full command** (replace `<version>` if needed): | |
```sh | |
~/Library/Android/sdk/build-tools/34.0.0/aapt dump permissions android/app/build/outputs/apk/release/app-release.apk | |
``` | |
If you want to check the debug APK, use: | |
```sh | |
~/Library/Android/sdk/build-tools/34.0.0/aapt dump permissions android/app/build/outputs/apk/debug/app-debug.apk | |
``` | |
--- | |
### **What You Should See** | |
The output will look like: | |
``` | |
package: name='com.yourcompany.yourapp' versionCode='1' versionName='1.0' | |
uses-permission: name='android.permission.INTERNET' | |
uses-permission: name='android.permission.CAMERA' | |
``` | |
**If you see `READ_MEDIA_IMAGES` or `READ_MEDIA_VIDEO` in the output, those permissions are still present.** | |
--- | |
### **Summary Table** | |
| Step | Command | | |
|------|---------| | |
| Release APK | `~/Library/Android/sdk/build-tools/34.0.0/aapt dump permissions android/app/build/outputs/apk/release/app-release.apk` | | |
| Debug APK | `~/Library/Android/sdk/build-tools/34.0.0/aapt dump permissions android/app/build/outputs/apk/debug/app-debug.apk` | | |
## 2. **Check the Merged Manifest in the Built APK/AAB** | |
Sometimes, dependencies add permissions via their own manifests. The final APK/AAB manifest is a merge of all manifests (your app + libraries). | |
### **How to Check the Merged Manifest:** | |
#### **A. Using Android Studio** | |
1. Build your app (Debug or Release). | |
2. In Android Studio, go to: | |
``` | |
app/build/outputs/apk/release/app-release.apk | |
``` | |
3. Open the APK with Android Studio’s APK Analyzer (Build > Analyze APK). | |
4. Navigate to `AndroidManifest.xml` and search for the permissions. | |
#### **B. Using AAPT (Command Line)** | |
1. Locate your built APK (e.g., `android/app/build/outputs/apk/release/app-release.apk`). | |
2. Run: | |
```sh | |
$ANDROID_HOME/build-tools/<version>/aapt dump permissions app-release.apk | |
``` | |
Replace `<version>` with your build-tools version (e.g., 34.0.0). | |
**Example Output:** | |
``` | |
uses-permission: name='android.permission.INTERNET' | |
uses-permission: name='android.permission.CAMERA' | |
``` | |
If you see `READ_MEDIA_IMAGES` or `READ_MEDIA_VIDEO` here, they are still present. | |
--- | |
## 3. **Check for Permissions in Dependencies** | |
- Some libraries (like `react-native-image-crop-picker`) may add permissions via their own manifests. | |
- You can search your entire project for these permissions: | |
```sh | |
grep -r "READ_MEDIA_IMAGES" android/ | |
grep -r "READ_MEDIA_VIDEO" android/ | |
``` | |
- Remove or patch any occurrences found in library manifests. | |
--- | |
## 4. **Final Checklist Before Uploading** | |
- No restricted permissions in your merged manifest (check with AAPT or APK Analyzer). | |
- No restricted permissions in your app’s or dependencies’ manifests. | |
- Your app works as expected without those permissions. | |
--- | |
## **Summary Table** | |
| Step | Tool/Method | What to Check | | |
|------|-------------|---------------| | |
| 1 | Manifest file | No restricted permissions in your manifest | | |
| 2 | APK Analyzer / AAPT | No restricted permissions in merged manifest | | |
| 3 | grep | No restricted permissions in dependencies | | |
| 4 | Test app | App works without those permissions | | |
--- | |
**Would you like a command to run on your machine to check your built APK for these permissions?** If so, let me know your build-tools version or if you want to use the default one! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment