Android studio database inspector does not show any databases

Viewed 33633

I am on Android studio 4.1 beta 1 . I installed my app on my device and opened Database Inspector and nothing shows up . Am I supposed to do anything else ?

enter image description here

I am using room database . I can see the database on device . Why is the database not showing up in database inspector?

18 Answers

In my case, it showed me the same process a lot of times. And none of them worked.

The solution was Invalidating the Cache:

File -> Invalidate Caches/Restart -> Invalidate and restart

After that everything started working again.

If you are using Android Studio Arctic Fox | 2020.3.1 then Database Inspector is under App Inspection. As below.

enter image description here

I solved this problem by uninstall and then installing app again. Formerly when I had face to this issue, I could run database inspector just by close/open app but now it start working just by uninstalling

Update

after more working with database inspector I understand some times it just needs a few seconds to connect and no need to do anything else

I face 2 cases:

  • First time connect to my device and database does not show, then i do an action to modify database -> database will show.

  • After I use ADB Idea to clean app data or uninstall (or go to settings and clear cache or uninstall app) -> database does not show -> restart device -> database will show

A workaround is to restart your device. Works for me

Well here is what was happening with me - Android Studio wouldn't pick up my connected device at all with the message "Error initializing adb : android debug bridge not found" when I tried to use Device File Explorer.

Turned out my project level sdk wasn't set correctly. Fixing that worked.

File -> Project Structure In Project, select valid Project SDK In Modules -> myapp_android -> Dependencies, select a valid Module SDK.

You should now be able to select connected devices from the database inspector. Flush your cache and restart (File -> Invalidate Caches/Restart and select "Invalidate Caches and Restart") for good measure.

In My Case, I forgot to open the database view inside the Database Inspector window as mentioned in the screenshot. Click on the database menu option as highlighted in yellow.enter image description here

Still so many problems with this how did it make it into stable? open the database inspector close your app reopen your app, app crashes,

Start your app open the database inspector restart your app, database inspector is gone cannot be brought back without uninstalling and reinstalling your app

Great

Enable the "keep database connection open". I think its not showing because of .close(). See the image for your reference.

See image

I faced the same problem, I Open the Layout inspector and after that, I open the Database inspector, It works for me. seems like a bug of android studio

Follow these steps,

  1. View -> Tool Windows -> App Inspection
  2. Run the project
  3. Then you can see the "Database Inspection"

Database Inspection in android studio arctic fox 2020.3.1 patch 3

[![][1]][1]
[1]: https://i.stack.imgur.com/QGyjz.png

In my case I was using an emulator and I came to know that its mentioned and configured storage was about full.

So I just wiped all data of emulator and restarted the app inspection tab now this time I was able to view the db tables in the inspector window.

I face this issue on many devices. Kill the app process and run again. The application should be in the foreground.

Every time I faced with this issue, I'd unplugged the usb cable, then plugged it again. Then make sure the database inspector window is open. After that, every time the database is accessed, it'd appear in the window

In my case, I had two databases in assets under the same directory and only one was showing on the inspector no mater how many times I killed and restarted the process. In the end I found that it was not showing up because I needed to store the second database file in a separate folder

structure assets > folder > db_file.db assets > other_folder.db > other_db_file.db

such that the folder and the database file had the same name.

Example assets > my_database.db > my_database.db

After that, both databases showed up on the database inspector

I was emptying the cache (cache and code_cache) at each startup of my application.

When I did comment the line and stop deleting the cache, and unplug/plug back the phone, I got the database inspector showing my tables back again.

  1. Select debug build variant.
  2. Keep the device connected and deploy the app on the device.
Related