You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法打开Android Device Monitor求助:Mac环境下报错及SQLite查看需求

Fixing Android Device Monitor Issues on Mac (Plus Alternative SQLite Viewing Methods)

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:

  1. 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
  2. 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
  3. 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 monitor app, select "Show Package Contents"
    • Go to Contents/MacOS and open the monitor shell 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
  4. 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
      

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 .db file and select Save As to download it to your Mac
  • 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 sqlite3 command:
      sqlite3 /path/to/your/downloaded/db/file.db
      
      Then run commands like .tables to list tables, or SELECT * 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 click Inspect
    • Go to the Resources tab, expand SQLite—you can view, query, and modify your database directly in the browser

内容的提问来源于stack exchange,提问作者jijo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:11:34