429

When I develop the project using Eclipse, the APK file goes on the emulator. But I want to upload my application to a real device. Is there a tool to build an APK file?

What is the process? Or is it possible to pull the APK file from the emulator?

Mario Carneiro
  • 1,548
  • 1
  • 18
  • 32
sean
  • 9,198
  • 22
  • 65
  • 80
  • 4
    Too many answers are about how to install the generated apk file or are answers that takes other concerns (key signing) into consideration. What if all I want is to generate the apk (in bin directory) as if I had clicked the "Run" button without any further questions or decisions? – Jarl Dec 14 '12 at 06:55
  • 1
    I am looking for exactly the same thing. BTW, using "export unsigned application package" in the Android tools is immensely slow and I have to specify the location each time, so not really suitable. – TommyTh Dec 14 '12 at 10:54
  • 1
    Below, Salil Pandit suggested to "set run to Manual and when you hit play it'll list applicable devices / AVDs as soon as you have done this, the APK is created - you don't actually have to fire up the emulator." That was what I needed. (Could warrant a separate question if it does not exist already?) – TommyTh Dec 14 '12 at 11:00
  • 2
    Sarwar Erfan's answer is much better. Why not changing the accepted answer? – NLemay Mar 15 '13 at 13:19

12 Answers12

400

When you run the project on the emulator, the APK file is generated in the bin directory. Keep in mind that just building the project (and not running it) will not output the APK file into the bin directory.

claws
  • 52,236
  • 58
  • 146
  • 195
anta40
  • 6,511
  • 7
  • 46
  • 73
  • 80
    Remember that that APK is not signed with your developer private key, so you shouldn't distribute or or upload it to the market. – Computerish Jan 05 '11 at 18:28
  • 17
    So, and if we only would like to build it but not to start a noisy emulator? – sergzach Jan 22 '12 at 20:54
  • 9
    An anonymous user attempted to edit this post to include a note that _this_ mechanism of getting an `.apk` file will get a _debug build_. If you want a release build, follow [Sarwar's answer](http://stackoverflow.com/a/4600933/377270) instead. – sarnold Feb 16 '12 at 22:45
  • 1
    and where is that bin's location ? –  Mar 16 '12 at 12:33
  • 3
    @sergzach set run to Manual and when you hit play it'll list applicable devices / AVDs as soon as you have done this, the APK is created - you don't actually have to fire up the emulator. That said, sarnold is right Sanwar's answer is better for releasing the app. – Salil Pandit Mar 29 '12 at 07:35
315

For testing on a device, you can connect the device using USB and run from Eclipse just as an emulator.

If you need to distribute the app, then use the export feature:

alt text

alt text

Then follow instructions. You will have to create a key in the process.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sarwar Erfan
  • 18,034
  • 5
  • 46
  • 57
173

There is no need to create a key and so forth if you just want to play around with it on your device.

With Eclipse:

To export an unsigned .apk from Eclipse, right-click the project in the Package Explorer and select Android Tools -> Export Unsigned Application Package. Then specify the file location for the unsigned .apk.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
thegreyspot
  • 4,079
  • 5
  • 28
  • 34
  • 3
    This seems like a good answer. However android lint errors prevent this from working... The standard "Run" action somehow succeeds in generating the apk file even with android lint errors. – Jarl Dec 14 '12 at 06:52
  • Works, although it make the .apk even if there are errors (compilation, ...) which could be a bad or a good thing. – Francisco Corrales Morales Apr 15 '14 at 15:52
  • Thanks for sharing. this is good enough for initial testing of the shared apk. – webgenius Mar 21 '15 at 19:23
  • this solution makes eclipse collapse too often,is there a `script` approach ? – zionpi Jan 11 '17 at 09:32
33

The APK file is in the /workspace/PROJECT_FOLDER/bin directory. To install the APK file in a real device:

  1. Connect your real device with a PC/laptop.

  2. Go to sdk/tools/ using a terminal or command prompt.

  3. adb install <FILE PATH OF .APK FILE>

That's it...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nirav
  • 5,700
  • 4
  • 34
  • 44
24

Just right click on your project and then go to

*Export -> Android -> Export Android Application -> YOUR_PROJECT_NAME -> Create new key store path -> Fill the detail -> Set the .apk location -> Now you can get your .apk file*

Install it in your mobile.

SAURABH_12
  • 2,262
  • 1
  • 19
  • 19
21

We can a make a signed and unsigned APK file. A signed APK file can install in your device.

For creating a signed APK file:

  1. Right-click the project in the Package Explorer

  2. Select Android Tools -> Export Signed Application Package.

  3. Then specify the file location for the signed .apk.

For creating an unsigned APK file:

  1. Right-click the project in the Package Explorer

  2. Select Android Tools -> Export Unsigned Application Package.

  3. Then specify the file location for the unsigned APK file.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ebin Sebastian
  • 1,291
  • 1
  • 13
  • 15
12

When you run your application, your phone should be detected and you should be given the option to run on your phone instead of on the emulator.

More instructions on getting your phone recognized: http://developer.android.com/guide/developing/device.html

When you want to export a signed version of the APK file (for uploading to the market or putting on a website), right-click on the project in Eclipse, choose export, and then choose "Export Android Application".

More details: http://developer.android.com/guide/publishing/app-signing.html#ExportWizard

Computerish
  • 9,590
  • 7
  • 38
  • 49
6

The bin/XXX.apk file can be built automatically as soon as you save any source file:

Window/Preferences, Android/Build, uncheck "skip packaging and indexing..."

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lanchon
  • 61
  • 1
  • 1
6

Eclipse 3.7 (Indigo): Go to Windows -> Preferences -> Android -> Build and uncheck "Skip packaging and dexing until export or launch"

Also, you can build it manually via Menu -> Project -> **Uncheck "Build automatically"**.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yousha Aleayoub
  • 4,532
  • 4
  • 53
  • 64
6

The simplest way to create signed/unsigned APKs using Eclipse and ADT is as follows:

  1. Right click your project in the "Project Explorer"
  2. Hover over "Android Tools"
  3. Select either "Export Signed Application Package" or "Export Unsigned Application Package"
  4. Select the location for the new APK file and click "Save".

    • NOTE: If you're trying to build a APK for beta distribution, you'll probably need to create a signed package, which requires a keystore. If you follow the "Signed Application" process in Eclipse ADT it will guide you through the process of creating a new keystore.

Hope this helps.

nenchev
  • 1,998
  • 28
  • 16
5

No one mentioned this, but in conjunction to the other responses, you can also get the apk file from your bin directory to your phone or tablet by putting it on a web site and just downloading it.

Your device will complain about installing it after you download it. Your device will advise you or a risk of installing programs from unknown sources and give you the option to bypass the advice.

Your question is very specific. You don't have to pull it from your emulator, just grab the apk file from the bin folder in your project and place it on your real device.

Most people are giving you valuable information for the next step (signing and publishing your apk), you are not required to do that step to get it on your real device.

Downloading it to your real device is a simple method.

L. D. James
  • 1,679
  • 1
  • 22
  • 35
  • -1, reason: Yeah, but this question was about 'building an .apk from Eclipse', not how to test an .apk app – Francisco Corrales Morales Apr 15 '14 at 15:49
  • The question was very clear of how to get the apk that he already has into a "real device". While all the other building, signing, and publishing suggestions are good suggestions, he can very easily get his apk that he already has in his emulator by downloading the current "apk" from his project sub-folder. – L. D. James Apr 18 '14 at 09:48
5

Right click on the project in Eclipse -> Android tools -> Export without signed key. Connect your device. Mount it by sdk/tools.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abiram
  • 51
  • 1
  • 1