You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
3.3 KiB

#!/bin/bash
# Android Emulator Network Verification Script
# Diagnoses network connectivity issues that cause ANRs and Play Services failures
# Author: Matthew Raymer
echo "🔍 Android Emulator Network Verification"
echo "========================================"
echo ""
# Check if emulator is running
if ! adb devices | grep -q "emulator.*device"; then
echo "❌ Error: No emulator detected!"
echo "Please start an emulator first"
exit 1
fi
echo "✅ Emulator detected"
echo ""
echo "📋 Network Diagnostics:"
echo ""
echo "1. 🔧 ADB Connection Status:"
adb devices
echo ""
echo "2. ✈️ Airplane Mode Status:"
AIRPLANE_MODE=$(adb -e shell settings get global airplane_mode_on 2>/dev/null)
if [ "$AIRPLANE_MODE" = "1" ]; then
echo " ❌ Airplane mode is ON - this will block network access"
echo " 💡 Fix: adb -e shell settings put global airplane_mode_on 0"
else
echo " ✅ Airplane mode is OFF"
fi
echo ""
echo "3. 🌐 Network Interfaces:"
echo " Network interfaces:"
adb -e shell ip addr | grep -E "(inet |UP|DOWN)" | head -10
echo ""
echo " Routing table:"
adb -e shell ip route | head -5
echo ""
echo "4. 🏓 DNS Resolution Tests:"
echo " Testing Google DNS (8.8.8.8):"
if adb -e shell ping -c1 8.8.8.8 >/dev/null 2>&1; then
echo " ✅ Google DNS reachable"
else
echo " ❌ Google DNS unreachable - host/VPN/firewall blocking"
fi
echo " Testing connectivity check (connectivitycheck.gstatic.com):"
if adb -e shell ping -c1 connectivitycheck.gstatic.com >/dev/null 2>&1; then
echo " ✅ Hostname resolution working"
else
echo " ❌ Hostname resolution failed - DNS issue"
fi
echo ""
echo "5. 🔍 Play Services Status:"
echo " Google Play Services:"
adb -e shell dumpsys package com.google.android.gms | grep -E "(versionName|enabled)" | head -2
echo ""
echo "6. 📊 Network Monitor Logs:"
echo " Recent network errors (last 10 lines):"
adb -e logcat -d | grep -E "(NetworkMonitor|ECONNREFUSED|UnknownHostException)" | tail -5
echo ""
echo "🎯 Diagnosis Summary:"
echo ""
# Determine issue type
if [ "$AIRPLANE_MODE" = "1" ]; then
echo "❌ PRIMARY ISSUE: Airplane mode is ON"
echo " Solution: Turn off airplane mode"
elif ! adb -e shell ping -c1 8.8.8.8 >/dev/null 2>&1; then
echo "❌ PRIMARY ISSUE: No internet connectivity"
echo " Solutions:"
echo " - Check host VPN/killswitch settings"
echo " - Verify firewall rules allow emulator traffic"
echo " - Try: ./launch-emulator-network-fix.sh"
elif ! adb -e shell ping -c1 connectivitycheck.gstatic.com >/dev/null 2>&1; then
echo "❌ PRIMARY ISSUE: DNS resolution failure"
echo " Solutions:"
echo " - Use explicit DNS: -dns-server 8.8.8.8,1.1.1.1"
echo " - Check corporate proxy settings"
echo " - Try: ./launch-emulator-network-fix.sh"
else
echo "✅ Network connectivity appears normal"
echo " If still experiencing ANRs, check Play Services cache:"
echo " adb -e shell pm clear com.google.android.gms"
fi
echo ""
echo "🔧 Quick Fixes:"
echo " # Clear Play Services cache"
echo " adb -e shell pm clear com.google.android.gms"
echo " adb -e shell pm clear com.android.vending"
echo ""
echo " # Restart ADB"
echo " adb kill-server && adb start-server"
echo ""
echo " # Launch with network fixes"
echo " ./launch-emulator-network-fix.sh"