开发者

How to install an APK file on an Android phone?

I have a simple "Hello Android" application on my computer (Eclipse environment), and I have built an APK file. How do I transfer the APK file to my Android phone for t开发者_StackOverflow中文版esting?

My phone is Ideos running Android 2.2 (Froyo). My laptop has Windows Vista. I have the latest Android SDK installed.


Simply, you use ADB, as follows:

adb install <path to apk>

Also see the section Installing an Application in Android Debug Bridge.


If you have access to a Gmail account on the phone then an easy way (in terms of minimal set up effort) is to mail the .apk file to that Gmail account.

If you then access that account from the native Gmail app on the phone it recognises that the attachment is an app and offers an "Install" button.

As per other responses this approach also requires that you have selected USB debugging on the device.

Try this - it is remarkably easy ;-)


I quote Hello Android because I can't say it better ;-)

You need to enable USB debugging on the phone itself (by starting the Settings application and selecting Applications > Development > USB Debugging), install the Android USB device driver if you haven’t already (Windows only), and then plug the phone into your computer using the USB cable that came with the phone.

Close the emulator window if it’s already open. As long as the phone is plugged in, Eclipse will load and run applications on the phone instead. You need to right-click the project and select Run As > Android Application.


If you dont have SDK or you are setting up 3rd party app here is another way:

  1. Copy the .APK file to your device.
  2. Use file manager to locate the file.
  3. Then click on it.
  4. Android App installer should be one of the options in pop-up.
  5. Select it and it installs.


outside device,we can use :

adb install file.apk

or adb install -r file.apk

  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)

inside devices also, we can use:

pm install file.apk

or pm install -r file.apk

pm install: installs a package to the system.  Options:
    -l: install the package with FORWARD_LOCK.
    -r: reinstall an exisiting app, keeping its data.
    -t: allow test .apks to be installed.
    -i: specify the installer package name.
    -s: install package on sdcard.
    -f: install package on internal flash.
    -d: allow version code downgrade.

For more then one apk file on Linux we can use xargs and on windows we can use for loop.
Linux / Unix sample :

ls -1 *.apk | xargs -I xxx adb install -r xxx


Put the APK file into the tools folder in the Android SDK and give the path to tools in the command prompt and use the command:

adb install "name".apk file


Directly connect your Android device and select the USB debugging option in the device. Eclipse will itself find your device, and then just run the code.

Or alternatively, paste your APK file in the Android SDK platform-tools folder and from the command prompt install it like this:

D:......../platform-tools> adb install yourfile.apk.


For debugging:

  • Enable USB debugging on your phone (settings -> applications -> development).
  • Connect your phone to the computer, and make sure you have the correct drivers installed.
  • In Eclipse, run your project as an Android application (right click project -> run as -> Android application).

Installing the APK file:

  • Export the APK file, make sure you sign it (right click project -> Android tools -> export signed application package).
  • Connect your phone, USB debugging enabled.
  • from the terminal, use ADB to install the APK file (adb install path-to-your-apk-file.apk).


I was using the command prompt to manually install the .apk file on my device (Nexus 7) but the following should work in theory on any android device (after enabling the device for developer mode). This method was becoming cumbersome so I created a simple batch file so now all I have to do is double-click it and it installs for me (device must be plugged in to my development machine). Just create a text file and save it as .BAT with the following text (customize to accommodate your file paths):

cd C:\{**path to your install location**}\sdk\platform-tools

adb install C:\{**path to your .apk file**}\{**project/apk file name**}.apk


If you have mutliple devices/emulators, the commands above may not work. So, try these steps

  1. get device list by running adb devices. this will list devices and their IDs
  2. install apk using adb -s [DEVICE-ID] [-r|-l] <apk path>

Ensure you unlock your device in the process.


For what its worth, installing a system app to the /system/app directory will be:

adb push appname.apk /system/app/

Just ensure you're in the right directory where the target .apk file to be installed is, or you could just copy the .apk file to the platform-tools directory of the Android SDK and adb would definitely find it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜