Skip to content

Appendix E: Troubleshooting

Usage: When something goes wrong, come here first. This appendix consolidates every error pattern from across the book and labs into a single searchable reference. Errors are organized by the phase of the workflow where they occur: setup, decode/build, patching, installation, runtime, and injection.


ErrorCauseFix
command not found: javaJava not installed or not on PATHInstall: brew install openjdk@21 (macOS), sudo apt install openjdk-21-jdk (Linux)
UnsupportedClassVersionErrorJava version too old for patch-toolInstall Java 17 or higher. Verify with java --version
Error: could not find or load main classWrong working directory or corrupt JARRun from project root where patch-tool.jar lives
Unable to access jarfile patch-tool.jarNot in project root, or JAR missingcd to project root. Verify JAR exists with ls -la patch-tool.jar
ErrorCauseFix
command not found: adbplatform-tools not on PATHAdd export PATH="$PATH:$ANDROID_HOME/platform-tools" to shell profile
command not found: zipalignbuild-tools not on PATHAdd export PATH="$PATH:$ANDROID_HOME/build-tools/36.0.0" to shell profile
ANDROID_HOME is not setEnvironment variable missingAdd export ANDROID_HOME=~/Library/Android/sdk (macOS) or export ANDROID_HOME=~/Android/Sdk (Linux)
No build-tools foundSDK build-tools not installedInstall via Android Studio SDK Manager or sdkmanager "build-tools;36.0.0"
ErrorCauseFix
emulator: ERROR: No AVD specifiedAVD not createdCreate with Android Studio AVD Manager or avdmanager create avd
emulator: ERROR: x86_64 emulation currently requires hardware accelerationKVM not enabled (Linux) or HAXM not installed (Intel Mac)Linux: sudo apt install qemu-kvm. Intel Mac: install HAXM from SDK Manager
adb devices shows offlineEmulator still booting or adb connection staleWait 15-30 seconds. If persistent: adb kill-server && adb start-server
adb devices shows unauthorizedAuthorization dialog not acceptedCheck emulator screen for USB debugging prompt. Accept it.
Emulator extremely slowWrong architecture image (x86 on ARM or vice versa)Apple Silicon: use arm64-v8a image. Intel: use x86_64 image
PANIC: Broken AVD system pathSystem image missing or corruptReinstall system image via SDK Manager
ErrorCauseFix
command not found: apktoolNot installedbrew install apktool (macOS), manual install (Linux — see Appendix D)
brut.androlib.AndrolibException during decodeAPK uses newer resource format than apktool supportsUpdate apktool to 2.9.0+ or 3.0.1+
Exception in thread "main" brut.androlib.exceptions.InFileNotFoundExceptionAPK path is wrongVerify path with ls -la target.apk

ErrorCauseFix
Could not decode arsc fileResource table uses format apktool doesn’t supportUpdate apktool. If still fails, try apktool d --no-res target.apk -o decoded/ to skip resource decoding
W: Could not decode attr valueNon-standard attribute in manifestWarning only — usually safe to ignore
Only one smali/ directory (expected multiple)apktool 2.x behavior vs 3.xNormal for apktool 2.x. All classes are in smali/. With 3.x you get smali_classes2/, etc.
Decode succeeds but smali/ is emptyAPK is a split APK and base.apk was not decodedEnsure you decoded base.apk, not a config split
ErrorCauseFix
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not execaapt/aapt2 binary missing or wrong architectureEnsure build-tools are installed. On Apple Silicon, use ARM build-tools
error: resource X not foundResource reference broken during decode/editDid you accidentally edit a resource XML with invalid syntax? Check the error line number
W: error: failed to open directory: res/values-XXXLocale directory corruptionDelete the problematic locale directory — it’s usually not needed
Build produces APK but it’s much smaller than expectedResources excluded or --no-res was used during decodeRe-decode without --no-res flag
ErrorCauseFix
Failed to load signer "signer #1"Wrong keystore password or aliasDouble-check --ks-pass and --ks-key-alias values
The specified keystore file does not existKeystore path wrongCreate one: keytool -genkeypair -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 -storepass android -keypass android
zipalign: error: unsupportedAttempting to zipalign an already-signed APKRun zipalign BEFORE apksigner, not after
APK signed but apksigner verify failszipalign and apksigner from different build-tools versionsUse both from the same build-tools/XX.Y.Z/ directory

ErrorCauseFix
[-] Failed to decode APKapktool not on PATH or APK is corruptVerify apktool --version works. Try decoding manually first
[-] Application class not foundManifest has no android:name in <application>patch-tool should handle this by creating one. If it fails, check the APK is valid
[!] No Surface(SurfaceTexture) foundTarget doesn’t use Camera2Normal for CameraX-only targets. Expected warning, not an error
[!] No onLocationChanged(Location) foundTarget doesn’t use legacy LocationManagerNormal for modern targets using FusedLocationProvider
[!] No onSensorChanged(SensorEvent) foundTarget doesn’t register a SensorEventListenerNormal — means liveness is purely visual, no sensor correlation
[-] Error during rebuildModified smali has syntax errorsCheck patch-tool output for specific file/line. Manual smali edits may conflict
All lines show [!] warnings, no [+] successesWrong target APK or APK already strippedVerify you’re patching the correct APK. Re-pull from device if needed

ErrorCauseFix
INSTALL_FAILED_UPDATE_INCOMPATIBLEAPK signed with different key than installed versionadb uninstall <package> first, then install
INSTALL_FAILED_NO_MATCHING_ABISAPK built for ARM but emulator is x86, or vice versaUse matching architecture. ARM APK needs ARM emulator
INSTALL_FAILED_OLDER_SDKAPK’s minSdkVersion higher than emulator’s API levelUse emulator with API level >= APK’s minimum
INSTALL_FAILED_INVALID_APKAPK not signed, not aligned, or corruptRe-run: apktool b, then zipalign, then apksigner sign
INSTALL_FAILED_VERIFICATION_FAILURESignature scheme issueTry signing with --v1-signing-enabled true --v2-signing-enabled true
INSTALL_PARSE_FAILED_NO_CERTIFICATESAPK unsignedRun apksigner sign on the APK
pm grant returns Unknown permissionApp doesn’t declare that permission in its manifestHarmless — skip that permission
appops set returns errorAPI level too old for that appops command, or wrong package nameVerify package name. MANAGE_EXTERNAL_STORAGE requires API 30+

SymptomCauseFix
App crashes immediately (no UI)Signature verification killing the processFind and neutralize signature check (Ch 15, Technique 2)
Splash screen appears then crashesDEX integrity check or delayed signature checkCheck logcat: adb logcat | grep -iE "integrity|signature|tamper"
”App not installed” toastInstallation didn’t completeRe-run adb install -r patched.apk
Black screen then crashMissing dependency or resource error from rebuildCheck logcat for ClassNotFoundException or ResourceNotFoundException
java.lang.VerifyError in logcatSmali patch introduced a type conflictReview manual smali edits. Register type mismatch at a branch merge point. See Ch 13
SymptomCauseFix
Security warning dialog on launchInstaller verification triggeredNeutralize installer check (Ch 15) or nop the dialog
App launches but features are grayed outIntegrity check silently blocking functionalityGrep for integrity checks that set feature flags rather than crashing
Network calls fail with SSL errorsCertificate pinning activePatch network_security_config.xml and nop CertificatePinner calls (Ch 15)
App works but crashes after 30-60 secondsDelayed integrity check or server-side attestation failureCheck logcat for the exception. May need to nop a periodic check
”Mock location detected” messageApp detected mock location despite patchesCheck patch output for isFromMockProvider/isMock. May use non-standard detection
Camera preview shows real camera, not injected framesFrameInterceptor not armedPush frames to /sdcard/poc_frames/ and force-stop + relaunch the app

SymptomCauseFix
No FRAME_DELIVERED in logcatPayload directory empty or wrong pathadb shell ls /sdcard/poc_frames/ — verify PNGs exist
FRAME_DELIVERED but no FRAME_CONSUMEDApp doesn’t call toBitmap() on this code pathCheck recon — may use getPlanes() or getImage() instead. Hooks should cover all paths
FRAME_DELIVERED but ML Kit finds no faceFrame quality too low, face too small, or using gray test framesUse real face frames (Option A) or ensure face fills 60%+ of the 640x480 frame
FrameStore: 0 files loadedDirectory exists but contains no PNGsVerify filenames end in .png (lowercase). FrameStore scans for PNG specifically
Frame delivery rate very low (< 5 fps)Emulator limitationNormal on emulators. Physical devices deliver at full camera frame rate
Camera preview shows injected frames but ML Kit bounding box flickersFrame sequence too short, causing visible loopingAdd more frames (45-75 for smooth looping at 15 fps)
intercept swapped ImageProxy but app still shows live cameraApp has two camera instances — preview and analysis are separateThe analysis pipeline is hooked (ML Kit sees your frames), but the preview may still show real camera. This is normal — the SDK processes your frames
QR code not decodedQR too small in 640x480 frame, or resolution mismatchRegenerate QR code at larger size. Ensure it fills significant portion of the frame
SymptomCauseFix
No LOCATION_DELIVERED in logcatApp hasn’t queried location yetNavigate to the location/geofence screen in the app
Coordinates delivered but geofence failsCoordinates outside the expected radiusRe-check recon for exact geofence center and radius. Tighten coordinates
LOCATION_CALLBACK_HIT is zero but LOCATION_DELIVERED > 0App uses getLastLocation() not continuous callbacksNormal — different API path, still hooked
Location delivered but map shows wrong positionConfig JSON has lat/lng swappedDouble-check: latitude is the first value (e.g., 40.7580 for NYC), longitude second (-73.9855)
JSONException when loading location configMalformed JSONValidate with python3 -m json.tool /sdcard/poc_location/config.json
SymptomCauseFix
No SENSOR_DELIVERED in logcatApp has no SensorEventListenerVerify recon — onSensorChanged may not exist in this target
SENSOR_DELIVERED but SENSOR_LISTENER_HIT is zeroWrong sensor type — app listens for gyroscope but you only inject accelerometerCheck which TYPE_* constants appear in recon. Configure all required types
Liveness fails despite frame injectionSensor data doesn’t match visual motionMatch sensor config to camera frames. Head tilt left = corresponding accelerometer shift
Sensor values look wrong in logcatConfig values incorrectGravity magnitude should be ~9.81. Check that sqrt(accelX^2 + accelY^2 + accelZ^2) ≈ 9.81

SymptomCauseFix
App crashes immediately after your smali editNop’d the wrong branch or broke method structureVerify .locals count >= highest register used. Check you didn’t nop past a required instruction
Forced return true but app still failsMultiple call sites — you patched one but another still runs the real checkgrep -rn "verifySignature|checkIntegrity" to find ALL call sites
Nop’d the branch but app now has a blank screenFailure path shows UI (error fragment) rather than crashingTrace the control flow more carefully. The “success” path may need to be explicitly taken
Certificate pinning bypassed but API calls return 401/403Server rejects requests without valid client certificate or attestation tokenServer-side attestation — client-side patching alone cannot fix this
App works after evasion but crashes after patch-tool runspatch-tool modified a class that conflicts with your evasion editsCheck if your manually patched method was also targeted by the patch-tool. Resolve the conflict
VerifyError after smali editsRegister type conflict at a merge pointUse different registers for different types. Do not reuse a register for both int and object across branches

SymptomCauseFix
JSONException at runtime after editing configInvalid JSON syntax (missing comma, bracket, or quote)Validate: python3 -m json.tool decoded/assets/config.json
NullPointerException after removing a JSON keyApp expected the key to existDon’t remove keys — change their values instead
ML model replacement causes crashReplacement model has different input/output tensor shapesInspect original model’s tensor shapes and match them exactly
Firebase Remote Config edits have no effectApp successfully fetched server-side values that override defaultsBlock Firebase connectivity or edit the fetched config cache
Edited XML resource causes build failureXML syntax error (unclosed tag, invalid character)Check apktool error output for the specific line number
Asset edit survives rebuild but not patch-toolpatch-tool unexpectedly modified the asset directoryVerify after patch-tool: diff decoded/assets/ work/assets/ to check for changes

When something goes wrong and you don’t know which phase the problem is in:

Terminal window
# Step 1: Check logcat for the smoking gun
adb logcat -d | grep -iE "exception|error|fatal|crash|killed|tamper|integrity|signature" | tail -20
# Step 2: Check if the app is even running
adb shell ps | grep <package>
# Step 3: Check if hooks are active
adb logcat -d -s HookEngine | tail -5
# Step 4: Check if payloads are on device
adb shell ls -la /sdcard/poc_frames/
adb shell ls -la /sdcard/poc_location/
adb shell ls -la /sdcard/poc_sensor/
# Step 5: Check permissions
adb shell dumpsys package <package> | grep -A 20 "granted=true"
# Step 6: Get the full crash trace
adb logcat -d | grep -A 30 "FATAL EXCEPTION" | head -40

If you have been debugging the same issue for more than 5 minutes without progress:

  1. Re-read the error message. The answer is almost always in the message itself. Android error messages are specific.
  2. Check the patch-tool output. Did the hook you expected actually fire? A [!] where you expected a [+] means your recon was wrong.
  3. Re-run the Lab 0 health check. Environment issues masquerade as patching failures. Rule them out.
  4. Start from a clean state. adb uninstall, adb install fresh, push payloads again, relaunch. Stale state causes 30% of debugging time.
  5. Check this appendix. The error you’re seeing is probably listed above with its fix.