I need to install an APK on a phone with no built in file browser, and no connection (wifi/mobile). The LG Optimus M has no built in file browser... Not sure why, but it is making things very difficult. I was thinking if I could put an app in a special place on an SD card, or auto-run an APK install.
ADB is also not an option due to usb driver issues. I know this is pretty limited...
EDIT: I got down voted because you didn't read? There is no wifi/mobile connection available. Downloading a file manager etc. from market not an option.
Enable usb debugging
Install the drivers and android sdk
Connect the phone through usb to your computer
Call the following program from the command prompt: adb install
application.apk
Adb will now install your application
According to the about of just running adb, you can use the following command line arguments:
adb install [-l] [-r] [-s] [--algo <algorithm name> --key <hex-encoded key> --iv <hex-encoded iv>] <file>
- push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-s' means install on SD card instead of internal storage)
('--algo', '--key', and '--iv' mean the file is encrypted already)
Why not download one of the MANY file browsers in the market? May I suggest my favorite which is Astro File Manager
If you have a terminal emulator app on the device, you can put MyApp.apk on the SD card and run this, which should open the package installer:
am start -a "android.intent.action.VIEW" -d "file:///mnt/sdcard/external_sd/MyApp.apk" -t "application/vnd.android.package-archive"
You might need to change that path depending on your device — see How can I determine storage directory from ADB?
You will also need to enable the Unknown Sources option in the device settings.
Why not download astro file manager? it works great. Other than that I would host the apk on a server and download it from the phone.
Related
Lets say we have downloaded, built and flashed AOSP source code. Now a change to a system app is made (e.g. changed a constant in the packages/apps/Nfc package).
The next step is to build it, and there are two ways to do it:
cd packages/apps/Nfc; mm
or
mmm Nfc
This will create out/target/product//system/app/NfcNci/NfcNci.apk file
Which is the proper way to update the system app?
I tried using adb install NfcNci.apk but no success:
~/android/aosp-7.1.2-3.10-v2/out/target/product/kugo/system/app/NfcNci$ adb install NfcNci.apk
Failed to install NfcNci.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install com.android.nfcnci without first uninstalling.]
~/android/aosp-7.1.2-3.10-v2/out/target/product/kugo/system/app/NfcNci$ adb install -r NfcNci.apk
Failed to install NfcNci.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.android.nfcnci-1: Package /data/app/com.android.nfcnci-1/base.apk code is missing]
Found a way to easily 're-install' the app itself (let's put Settings app as an example):
mmm packages/apps/Settings # Build the module
adb root ; adb remount # Restart adbd as root and mount /system as writable
adb push out/target/product/<device_name>/system/priv-app/Settings /system/priv-app # Push the built files to the device
Then force-close and restart the app (by swiping it from Recents). No need to reboot device in order to take changes
NOTE: Depending on the app, the path may be on system/app instead of /system/priv-app
Another way is to:
copy the new apk to the sdcard of the device with adb push
mount /system read write: mount -o rw,remount,rw /system
copy your new .apk from /sdcard over your old .apk in /system/app
remove the .odex file of your old .apk
reboot the device
For development you can use a simple script for this steps.
Check build/envsetup.sh file - there's also commands mmp and mmmp to build and push a module to connected device. Also adb sync can be used to sync whole image, so if you updated a module, changed files will be pushed to device.
Also you can put the changed files via regular `adb push' and reboot device.
I do not know if system apps can be updated via adb install, probably yes, but I think you need to increment build number in the manifest file.
I do not think you can uninstall a system app with adb install -r, as apps can't be removed from system partition, only from data. I do not know why you are getting INSTALL_FAILED_INVALID_APK in that case, may be because app manager can't uninstall the base system apk indeed.
If you attach android device to PC you can browse files and dirs. It is possible to get this directory using Environment.getExternalStorage(). You can use it from your application and create accessible files and dirs. It works fine.
On my devices this path looks like /storage/emulated/0 and if i try adb push to this directory i will get access denied error. Is it possible to copy files using adb to the same folder as Windows Explorer does?
D:\...\tools>adb push ACCOUNTS.DB /storage/emulated/0
failed to copy 'ACCOUNTS.DB' to '/storage/emulated/0': Permission denied
58969 KB/s (606505 bytes in 0.010s)
I'm implementing automated import/export and i want files to be accessible without adb shell in case anything will go wrong.
Currently using variable$EXTERNAL_STORAGE as workaround, it works for both adb and application.
Device: Asus Fonepad 7, Android 5.0, tried Genymotion Custom Tablet 6.0 - works.
Try to use /sdcard/. Although it is strongly discouraged to do this in code. It seems to be the only way with adb :
$ adb push somefile /storage/emulated/0/somefile
[100%] /storage/emulated/0/somefile
adb: error: failed to copy 'somefile' to '/storage/emulated/0/somefile': Read-only file system
$ adb push somefile /sdcard/somefile
[100%] /sdcard/somefile
By the way, on my device they don't have the same value : Environment.getExternalStorage() points to /storage/emulated/0/ while /sdcard points to /storage/emulated/legacy.
It's pretty easy, internal storage is unavailable on non-rooted devices. So as was mentioned in bwt answer you just need to push your data to sdcard :
adb push somefile /sdcard/somefile
With retrieving files from your filesystem you'll also have few problems. But with the case of pulling a database from a debug application - you'll just need to change file permission via chmod.
Here you have a useful link - XDA guys about adb
I have installed an Android app on my phone which I have created myself on java. The App got successfully installed on the device but I am not able to locate the package where it has installed.
How to find the path of the installed application?
You will find the application folder at:
/data/data/"your package name"
you can access this folder using the DDMS for your Emulator. you can't access this location on a real device unless you have a rooted device.
System apps installed /system/app/ or /system/priv-app. Other apps can be installed in /data/app or /data/preload/.
Connect to your android mobile with USB and run the following commands. You will see all the installed packages.
$ adb shell
$ pm list packages -f
An application when installed on a device or on an emulator will install at:
/data/data/APP_PACKAGE_NAME
The APK itself is placed in the /data/app/ folder.
These paths, however, are in the System Partition and to access them, you will need to have root. This is for a device. On the emulator, you can see it in your logcat (DDMS) in the File Explorer tab
By the way, it only shows the package name that is defined in your Manifest.XML under the package="APP_PACKAGE_NAME" attribute. Any other packages you may have created in your project in Eclipse do not show up here.
->List all the packages by :
adb shell su 0 pm list packages -f
->Search for your package name by holding keys "ctrl+alt+f".
->Once found, look for the location associated with it.
The package it-self is located under /data/app/com.company.appname-xxx.apk.
/data/app/com.company.appname is only a directory created to store files like native libs, cache, ecc...
You can retrieve the package installation path with the Context.getPackageCodePath() function call.
/data/data/"your app package name "
but you wont able to read that unless you have a rooted device
I got an APK from the Internet.
Can I install and run the APK on the emulator?
If yes, how to do it?
Yes it is possible
first copy that .apk file into "platform-tools" folder of your android-SDK then open the command prompt and go to "platform-tools" folder now type "adb install _" here underline means your .apk file name. then press enter. it's DONE
Be sure that your emulator is running.
Use adb to install apk on emulator (or any connected device as well):
adb install file.apk
Re-install, keeping application data:
adb install -r file.apk
adb documentation is available here: http://developer.android.com/tools/help/adb.html
Yes you can.
Easiest way is to download the apk file from within the browser on the emulator, then install it from the notifications menu.
Alternatively, you can install the Android SDK (which you might already have done if you have the emulator) and use adb install my.apk which should install to any available device (so long as only one is available). Use adb devices to check what devices are available - when you run the emulator, it should show up there.
N.B. you will need to enable unknown sources in the applications menu of settings for this to work.
Place it in your host and download the .apk file from your emulator browser.
Yes!
Place your .apk file in the platform-tools folder of SDK, go to command prompt (path to ADB) and run the following command:
adb install your_apk_file.apk
I'm not sure if it will work, but try to open the File Explorer of the emulator through DDMS perspective in Eclipse, and copy/paste your apk in a folder. Then navigate to that folder from your emulator and launch the apk.
I have written a simple android app and it runs in the emulator.
Now how do I actually copy it to my phone? I have HTC's Eris. When I attach it with USB it asks me If I want to mount it as a USB mass storage device. I then see it in my drive list.
the directories on the device are:
albumthumbs
amazonmp3
com.google.android.apps.listen
ComicReader
data
DCIM
download
media
music
rosie_scroll
Now what should I copy from my Project directory and where should I put it?
And is there any other process I need to run to "install" my app?
The adb tool provides a command for installing an application onto the phone, adb install .... It takes the .apk file as an arguement. adb --help has a bit more info.
If you are running Eclipse, you can setup Eclipse to publish the application to a connected device.
http://developer.android.com/guide/developing/device.html
You can also simply copy the .apk file to the sdcard and navigate to it using a file manager such as Astro. Long press on it, and Astro will install it for you.
You should be able to use HTC Sync, if you are on Windows..
At least for Hero, it will automatically install APK files on my phone, when I double click them
Download: http://www.htc.com/us/support/droid-eris-verizon/downloads/
Install ADB driver. Have your phone in USB debugging mode. In an opened eclipse code press ctrl+F11. it will show your device. Run through it