简体   繁体   中英

adb -d shell “run-as …” not working on Android O

Has something changed that commands like the following below no longer work on Android O?

adb -d shell "run-as package.name cat /data/data/package.name/databases/foo.db" > foo.db

Running:

  • Build : OPP2.170420.019
  • Device : Nexus 6P

I have tried endless amounts of ways but even cat or cp to the /sdcard does nothing. I am guessing some permission has changed and we can no longer use run-as package.name.

The only way that I am able to get data from my non-rooted Android O device is to use a FileProvider and copy to the /sdcard.

Does anyone have success using run-as on a debug package? Anyone having the same issues as I am?

I don't know the answer to my specific question but want to share my new findings (maybe obvious to some).

After testing Android Studio 3.0 Canary 1, there is a new Device File Explorer that allows easy downloading and even syncing the latest DB!

Android Studio 3 Canary 1  - 设备文件资源管理器

This is such a powerful feature for anyone that needs to grab files of any sort from their devices in development. The cat command was never perfect and always screwed up the DB every once in a while.

This File Explorer + SQLPro for SQLite is gold for any Android Development that has a DB!

Will leave the question open in case someone does have a reason or solution to my original problem. Plus I would feel like a douche accepting my own answer. :)

Looks like run-as will set current directory to /data/data/packageName.

I think the following would work:

adb -d shell "run-as package.name cat databases/foo.db " > foo.db

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM