无法打开Android Device Monitor求助:Mac环境下报错及SQLite查看需求
Hey there, let's tackle this problem head-on. The core issue here is that Android Device Monitor (ADM) is outdated and has poor compatibility with Java 9—that's why you're seeing those errors even after reinstalling JDK and Android Studio. Let's go through solutions to get ADM working, plus better alternatives for viewing SQLite databases.
Getting ADM to Run Properly
ADM was built for older Java versions, so downgrading to Java 8 is the most reliable fix:
Install Java 8 JDK
- Grab either Oracle's Java 8 JDK or OpenJDK 8 (both work fine). Once installed, note its path—usually something like
/Library/Java/JavaVirtualMachines/jdk1.8.0_xxx.jdk/Contents/Home
- Grab either Oracle's Java 8 JDK or OpenJDK 8 (both work fine). Once installed, note its path—usually something like
Configure Android Studio to use Java 8
- Open Android Studio, go to
File > Project Structure > SDK Location - Under
JDK location, browse to and select the Java 8 path you noted earlier
- Open Android Studio, go to
Force ADM to use Java 8
- ADM might still try to use Java 9 by default. Navigate to its install path:
/Users/[YourUsername]/Library/Android/sdk/tools/monitor - Right-click the
monitorapp, select "Show Package Contents" - Go to
Contents/MacOSand open themonitorshell script in a text editor - Add this line at the very top to set the Java 8 home:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_xxx.jdk/Contents/Home - Save the script, then try opening ADM again
- ADM might still try to use Java 9 by default. Navigate to its install path:
Run ADM via Terminal (as a fallback)
- If the above doesn't work, open Terminal and run this command (replace paths with your own):
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_xxx.jdk/Contents/Home && /Users/[YourUsername]/Library/Android/sdk/tools/monitor
- If the above doesn't work, open Terminal and run this command (replace paths with your own):
Better Alternatives for Viewing SQLite Databases
ADM is pretty clunky these days—here are far smoother options:
1. Android Studio's Built-in Device File Explorer + Local SQLite Tool
- Step 1: Extract the database file
- Open Android Studio, click
View > Tool Windows > Device File Explorer(or find it in the right sidebar) - Navigate to your app's database folder:
data/data/[YourAppPackageName]/databases/ - Right-click your
.dbfile and selectSave Asto download it to your Mac
- Open Android Studio, click
- Step 2: View it locally
- Use DB Browser for SQLite (free, open-source) to open the downloaded file—you can browse tables, run queries, and edit data easily
- Or use the terminal's built-in
sqlite3command:
Then run commands likesqlite3 /path/to/your/downloaded/db/file.db.tablesto list tables, orSELECT * FROM [TableName];to query data
2. Stetho (Facebook's Debug Tool)
This is my go-to for in-app database debugging—no need to extract files:
- Add dependencies to your app's build.gradle:
dependencies { implementation 'com.facebook.stetho:stetho:1.5.1' implementation 'com.facebook.stetho:stetho-sqlite:1.5.1' } - Initialize Stetho in your Application class:
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); Stetho.initializeWithDefaults(this); } } - Use it:
- Run your app on a device/emulator
- Open Chrome, go to
chrome://inspect, find your app in the list, and clickInspect - Go to the
Resourcestab, expandSQLite—you can view, query, and modify your database directly in the browser
内容的提问来源于stack exchange,提问作者jijo

