This document describes common errors you may encounter when using OhMyG0sh and how to resolve them.
Error Message:
APK Error: APK file doesn't exist or is not accessible
APK: /path/to/app.apk
Context: Verify the file path and permissionsCauses:
- File path is incorrect
- File doesn't exist
- Insufficient read permissions
- File is on unmounted drive
Solutions:
- Verify the file exists:
ls -la /path/to/app.apk - Check file permissions:
chmod 644 /path/to/app.apk - Use absolute path instead of relative path
- Ensure the file extension is
.apk
Example:
// ❌ Wrong - relative path might be incorrect
final scanner = OhMyG0sh(apkPath: '../app.apk');
// ✅ Correct - use absolute path
final scanner = OhMyG0sh(apkPath: '/home/user/apps/app.apk');Error Message:
JADX Error: jadx binary not found in PATH
Exit Code: -1
Context: Install jadx using:
macOS: brew install jadx
Linux/Windows: https://github.com/skylot/jadx/releases
Or provide explicit path with --jadx optionCauses:
- JADX is not installed
- JADX is not in system PATH
- Wrong JADX path provided
Solutions:
-
Install JADX:
# macOS brew install jadx # Linux (using apt) sudo apt install jadx # Manual installation # Download from https://github.com/skylot/jadx/releases # Extract and add to PATH
-
Provide explicit path:
final scanner = OhMyG0sh( apkPath: 'app.apk', jadxPath: '/usr/local/bin/jadx', );
-
Verify installation:
which jadx jadx --version
Error Message:
JADX Error: jadx decompilation failed
Exit Code: 1
Context: JADX exited with code 1. Check logs:
stdout: /tmp/ohmyg0sh-xyz/jadx_stdout.log
stderr: /tmp/ohmyg0sh-xyz/jadx_stderr.log
Try running with --args "--log-level DEBUG" for more detailsCauses:
- Corrupted APK file
- Unsupported APK format
- Obfuscated or protected APK
- Insufficient memory
- JADX version incompatibility
Solutions:
-
Check APK integrity:
unzip -t app.apk
-
Enable debug logging:
await scanner.run(jadxExtraArgs: ['--log-level', 'DEBUG']);
-
Continue on errors (if partial results acceptable):
final scanner = OhMyG0sh( apkPath: 'app.apk', continueOnJadxError: true, // Default is true );
-
Increase memory for large APKs:
export JAVA_OPTS="-Xmx4g"
-
Try different JADX options:
await scanner.run(jadxExtraArgs: [ '--no-res', // Skip resources '--no-imports', // Don't add imports '--deobf', // Enable deobfuscation ]);
Error Message:
Configuration Error: regexes.json not found in any standard location
File: regexes.json
Searched paths:
- /app/config/regexes.json
- /current/dir/config/regexes.json
- /package/install/config/regexes.json
Solutions:
1. Provide explicit path with --pattern option
2. Place regexes.json in ./config/ directory
3. Ensure package installation is completeCauses:
- Configuration file missing
- Wrong working directory
- Incomplete package installation
- Custom path not provided
Solutions:
-
Create config directory and file:
mkdir -p config cp node_modules/ohmyg0sh/config/regexes.json config/
-
Provide explicit path:
final scanner = OhMyG0sh( apkPath: 'app.apk', patternPath: '/path/to/custom-patterns.json', );
-
Verify package installation:
dart pub get # or flutter pub get
Error Message:
Configuration Error: Failed to parse configuration file
File: /path/to/regexes.json
Context: Invalid JSON: FormatException: Unexpected character...Causes:
- Malformed JSON syntax
- Missing commas or brackets
- Invalid escape sequences
- UTF-8 encoding issues
Solutions:
-
Validate JSON:
# Using jq jq . config/regexes.json # Using Python python -m json.tool config/regexes.json
-
Check common issues:
- Trailing commas (not allowed in JSON)
- Unescaped backslashes in regex patterns
- Missing quotes around keys/values
- Unclosed brackets or braces
-
Example valid format:
{ "AWS_Key": "AKIA[0-9A-Z]{16}", "API_Token": "(?i)token\\s*[:=]\\s*['\"]([^'\"]+)['\"]" }
Error Message:
Scan Error: Too many open files
File: /tmp/ohmyg0sh-xyz/sources/com/example/File.javaCauses:
- System file descriptor limit reached
- Too high concurrency setting
- Large APK with many files
Solutions:
-
Reduce concurrency:
final scanner = OhMyG0sh( apkPath: 'app.apk', scanConcurrency: 8, // Lower value );
-
Increase system limits (Unix/Linux):
# Temporary ulimit -n 4096 # Permanent (add to ~/.bashrc or ~/.zshrc) echo "ulimit -n 4096" >> ~/.bashrc
-
Check current limits:
ulimit -n
Error Message:
Scan Error: Permission denied
File: /tmp/ohmyg0sh-xyz/sources/protected.javaCauses:
- Insufficient permissions on temp directory
- SELinux or AppArmor restrictions
- Antivirus interference
Solutions:
-
Check temp directory permissions:
ls -la /tmp/ohmyg0sh-* -
Set proper permissions:
chmod -R 755 /tmp/ohmyg0sh-* -
Use custom temp directory:
export TMPDIR=/path/to/writable/temp
Error Message:
Pattern Error: Invalid regular expression
Pattern Name: Custom_Pattern
Pattern: [invalid(regex
Context: Unterminated character classCauses:
- Malformed regex syntax
- Unescaped special characters
- Unclosed groups or brackets
- Invalid escape sequences
Solutions:
-
Test regex patterns:
// Test pattern before adding to config try { final regex = RegExp(r'your_pattern_here'); print('Pattern is valid'); } catch (e) { print('Pattern error: $e'); }
-
Common regex issues:
{ "❌ Wrong": "[unclosed", "✅ Correct": "[a-z]+", "❌ Wrong": "(unclosed", "✅ Correct": "(group)", "❌ Wrong": "\\invalid", "✅ Correct": "\\\\valid" } -
Use online regex testers:
Error Message:
Out of memoryCauses:
- Large APK file
- Insufficient system memory
- Memory leak
- Too many concurrent operations
Solutions:
-
Increase Dart VM memory:
dart --old_gen_heap_size=4096 bin/ohmyg0sh.dart -f app.apk
-
Reduce concurrency:
final scanner = OhMyG0sh( apkPath: 'app.apk', scanConcurrency: 4, );
-
Process in batches:
- Split large APKs if possible
- Scan specific directories only
Error Message:
No space left on deviceCauses:
- Insufficient disk space for decompilation
- Temp directory on small partition
- Previous temp files not cleaned up
Solutions:
-
Check disk space:
df -h /tmp
-
Clean up old temp files:
rm -rf /tmp/ohmyg0sh-* -
Use different temp directory:
export TMPDIR=/path/to/larger/partition/tmp -
Ensure cleanup runs:
try { await scanner.run(); } finally { await scanner.cleanup(); // Always cleanup }
import 'package:ohmyg0sh/ohmyg0sh.dart';
Future<void> scanWithErrorHandling(String apkPath) async {
final scanner = OhMyG0sh(apkPath: apkPath);
try {
// Pre-flight checks
await scanner.integrityCheck();
print('✓ Pre-flight checks passed');
// Decompile
await scanner.decompile();
print('✓ Decompilation complete');
// Scan
await scanner.scanning();
print('✓ Scanning complete');
// Generate report
await scanner.generateReport();
print('✓ Report generated');
} on ApkError catch (e) {
print('❌ APK Error: ${e.message}');
print(' File: ${e.apkPath}');
if (e.context != null) print(' ${e.context}');
} on JadxError catch (e) {
print('❌ JADX Error: ${e.message}');
print(' Exit Code: ${e.exitCode}');
print(' Recoverable: ${e.isRecoverable}');
if (e.context != null) print(' ${e.context}');
} on ConfigurationError catch (e) {
print('❌ Configuration Error: ${e.message}');
print(' File: ${e.filePath}');
if (e.context != null) print(' ${e.context}');
} on ScanError catch (e) {
print('❌ Scan Error: ${e.message}');
print(' File: ${e.filePath}');
if (e.context != null) print(' ${e.context}');
} catch (e, stackTrace) {
print('❌ Unexpected Error: $e');
print(' Stack Trace: $stackTrace');
} finally {
// Always cleanup temp files
await scanner.cleanup();
print('✓ Cleanup complete');
}
}// Enable verbose output
final scanner = OhMyG0sh(
apkPath: 'app.apk',
showProgress: true,
);
// Use JADX debug logging
await scanner.run(jadxExtraArgs: ['--log-level', 'DEBUG']);
// Check JADX logs after failure
// Logs are in: /tmp/ohmyg0sh-*/jadx_stdout.log
// /tmp/ohmyg0sh-*/jadx_stderr.log// Fail-fast mode for CI/CD
final scanner = OhMyG0sh(
apkPath: 'app.apk',
continueOnJadxError: false, // Fail on any JADX error
showProgress: false, // Silent mode
);
try {
await scanner.run();
exit(0); // Success
} catch (e) {
print('Scan failed: $e');
exit(1); // Failure
}If you encounter an error not covered here:
-
Check the logs:
- JADX logs:
/tmp/ohmyg0sh-*/jadx_stdout.log - JADX errors:
/tmp/ohmyg0sh-*/jadx_stderr.log
- JADX logs:
-
Enable debug mode:
await scanner.run(jadxExtraArgs: ['--log-level', 'DEBUG']);
-
Report issues:
- GitHub: https://github.com/mathtechstudio/ohmyg0sh/issues
- Include: Error message, APK size, JADX version, OS version
-
Community support:
- Check existing issues on GitHub
- Search for similar problems
- Provide minimal reproduction example