Adb error while pulling an apk file from android device [duplicate] - android

I try to get the APK file of installed app on my Android phone, I followed this answer which says no need for root access.
I know Facebook app package name is com.facebook.katana, I see it with command adb shell pm list package.
Then, I tried in command line:
adb shell pm path com.facebook.katana
It returns:
package:/data/app/com.facebook.katana-2/base.apk
Then, I pull the apk file to my computer by:
adb pull /data/app/com.facebook.katana-2/base.apk
But output is:
adb: error: remote object '/data/app/com.facebook.katana-2/base.apk' does not exist
Why I can not get the APK but that answer says it works?

Pull the APK file from the Android device to the development box by setting destination path.
adb pull /data/app/com.facebook.katana-2/base.apk path/to/desired/destination
or use,
adb shell cat /data/app/com.facebook.katana-2/base.apk > app.apk

Insted of
adb pull /data/app/com.facebook.katana-2/base.apk
Use :
adb shell cat /data/app/com.facebook.katana-2/base.apk > app.apk
And your apk will be generated inside Your_Android_SDK_path\platform-tools

Install MyAppSharer from Google Play on the phone, run it, find your desired app, share it to your Google Drive (or email if file is small enough).
Works on Android 7.1, where the above adb pull commands don't work (at least not for me); says app doesn't exist. So just use the app, no need to run adb commands.

Try using adb pull to download a specified file from an emulator/device to your computer.
adb pull /data/app/com.facebook.katana-2/base.apk target/path

Related

Error installing (arcore-preview.apk) via USB/debugging mode on an Android Smartphone

I was following the instructions given on this https://developers.google.com/ar/develop/java/getting-started Google Developers Website but when I tried to install the APK file on my Android Device via Terminal (macOS)
Terminal gave me this error:
$ adb devices -l List of devices attached 93eafadd device usb:336592896X product:kenzo model:Redmi_Note_3 device:kenzo
$ adb install -r -d arcore-preview.apk Invalid APK file: arcore-preview.apk Sayans-iMac:~ sayan$
So I even transferred the APK to my Android device and tried to install it in the Android device it self manually, but I got this error: error parsing package!
I don't know why this is happening and I have also enabled USB debugging!
I had this same problem, but had not pointed adb to the right package:
adb install -r -d ~/Downloads/arcore-preview.apk
"Your download directory might vary."

Where does android studio save sqlite db on Linux dev machine?

I'd like to insert data directly into the sqlite database of my app but I cannot find it anywhere on android studio path, even on my root path:
$sudo find / -type f -name 'myapp.db'
I know several similar questions have been asked before but the answers for Windows did not help me on Ubuntu Linux. So appreciate your help.
Android Studio does not store the database locally in your computer. The databases only exist in the devices & every time you deploy to a new device, your database will be created new in that new device. That is why you can't find it in your computer. Here is where the database is located in the device:
/data/data/full_qualified_java_package_name/databases/database_name.db
Now if you would like to insert data directly, you can use the terminal in Android Studio & use ADB to pull the database off the emulator, modify it, and push it back in. Heck I am sure that if you know enough Linux you could probably insert what you need into it without pulling it from the device. Here are some sample commands for the Android Studio terminal for that:
~/Android/Sdk/platform-tools/adb devices
Get the device number, then:
~/Android/Sdk/platform-tools/adb -s emulator-#### pull /data/data/full_qualified_java_package_name/databases/database_name.db <local-filepath>
And to send it back in, it is just:
~/Android/Sdk/platform-tools/adb -s emulator-#### push <local-filepath> /data/data/full_qualified_java_package_name/databases/database_name.db
Example:
~/Android/Sdk/platform-tools/adb -s emulator-5554 pull /data/data/com.danielkaparunakis.stackoverflowquestions/databases/Questiondatabase.db /Users/DanielKaparunakis/Desktop
Additional tip: If you leave the blank when you pull like this:
~/Android/Sdk/platform-tools/adb -s emulator-5554 pull /data/data/com.danielkaparunakis.stackoverflowquestions/databases/Questiondatabase.db
It will automatically pull it to your project's root folder.
It will save it in the internal storage of every device, if you don't have a rooted device it will not allow you to pull it, but, if you are using an emulator you will be able to pull it.
https://developer.android.com/training/basics/data-storage/databases.html
You app's db is only on the device. You can pull it from any connected device – non-rooted physical devices as well. This script pulls it from the first device.
This trick is run-as <package name> which runs a shell the app's directory with full access to the app's data.
Replace $package with your app's package name and replace $db with the name of you app's db.
$ LC_ALL=C adb exec-out run-as $package cat databases/$db >db.sqlite
LC_ALL=C is to avoid some strange locale behavior on some systems.
adb is by default installed by Android Studio to ~/Android/Sdk/platform-tools/adb.
Update
The program 'adb' is currently not installed. To run 'adb' please ask your administrator to install the package 'android-tools-adb'
This is Ubuntu telling you that you can install it from the Ubuntu package manager.
Normally you would already have it as a part of Android Studio.
Update 2
I don't have a script yet for pushing it back since push and run-as don't work together. You would have to do something like this (untested).
$ adb push db.sqlite /sdcard/temp.sqlite
$ cat <<EOF | adb shell
run-as $package
cat /sdcard/temp.sqlite >databases/$db
exit
exit
EOF

ADB will not run

I just installed the android SDK with eclipse, straight from google's webpage, but for some reason it won't run, even when I am in the correct directory. When I use 'ls' (crunchbang linux) it show's that the file is there, but when I try to run it, it returns no such file or directory. Any ideas?
type script in your command if you adb configured.
adb stop-server
adb start-server
adb devices

redirect adb logcat to android avd

i want to redirect the Android developer tools logcat output to a file into the virtual device from a shell command, before than running the android app test.
The command i usually use to redirect the output to a file is:
adb shell logcat -v time - f log.txt packageName:F *:E > /folder/log.txt
but it puts the log file into a computer directory (/folder/ in this case).
I want to change it with a directory in the virtual device but like above, it says the folder does not exist.
There is way to do it via shell command?
You can simply do
adb shell "logcat -v time -f /mnt/sdcard/log.txt packageName:F *:E"
to accomplish it all in one command from the host shell. You do not need the redirect when you use the -f flag, in fact the redirect would not capture anything if you have directed the output of logcat to a file rather than to stdout.
If that is not working, it is either because you are using a version of Android which mounts the external storage at some other path, or you do not have an emulated sdcard attached to your virtual device.
You can investigate either of these problems by examining the output of
adb shell mount
If you do not have an sdcard at all on your AVD, follow the emulator documentation instructions for creating and attaching one.
For testing purposes only there may be other paths than the sdcard at which you can write, particularly on an emulator where the adb shell runs as root, for example on some versions /data/local or similar.
You can try this one adb shell then #logcat>/sdcard/log.txt now i am sure about the results.you just need a command prompt window to be opened for adb shell,that's not so bad i guess.

Can't install apk via adb, file DNE despite showing up using adb shell ls

I uploaded an apk using adb
adb push myAppName.apk /sdcard/
to double check:
adb shell ls /sdcard/
sure enough, it's there.
then:
adb install /sdcard/myAppName.apk
can't find '/sdcard/myAppName.apk' to install
Note* I tried adding the path in parentheses as suggested on an xda post but this didn't help.
Are there multiple sdcard directories where push defaults to one and install defaults to another? I tried using root explorer to find the files that adb install /sdcard/<TAB> suggests but I can't file these files in any dir.
adb install takes a file on your pc to install it. It doesn't look on the phone.
You can use:
adb shell pm install /mnt/sdcard/myAppName.apk
It will install apk from the device it self.
Please check Package Manager here.
Connect your device and the from the location where you have your app.apk do adb install app.apk . It will install it to your device.

Categories

Resources