Android get .apk file from emulator - android

I am newbie to the android development. Just out of curiosity i was wondering if it is possible to get back installed .apk file from android emulator ???

The question linked by #thepoosh indeed has some correct answers to your question, but it is not the accepted answer. Scroll down a bit to answer of either #plaisthos or #Pratik.
In short: your .apk resides in the /data/app directory on your emulator. Note: It probably has a name that differs from the name of the .apk file on your build machine, since the .apk get renamed to something that looks like your package name.
So, using adb shell:
- cd /data/app
- ls (and check the name of your .apk file)
- exit adb shell
- on commmandprompt: adb pull /data/app/your.filename.apk
Or from Eclipse use the fileexplorer tab as stated by #Pratik in the other thread.

you can copy the route if you are working in eclipse, the apk that you install in the emulator is the same that is in your project when you compile it, go to folder bin, select .apk ctrl+c and paste in your desktop for example.
How to extract the apk file from device:
First run your emulator.
if you are in windows, open cmd and go to platform-tools : in my case
cd C:\Program Files (x86)\Android\android-sdk\platform-tools
after that run adb as:
adb pull /data/app <the directory where do you wannt to save>
example:
adb pull /data/app C:\Users\tato469\Desktop\app
Access this folder and select your app.
NOTE: Look if only one emulator is running, else it will throw an error.

Are you trying to run the app on a device or do you just want the .apk?
TO run it on a device:
1) Click the project
2) Go to Run -> Run configurations -> Target tab
3) Select Always prompt to pick device then apply.
After which everytime you try and run the application it will let you select any plugged in devices
TO get the .apk
1) Right-click project file
2) Export
3) Follow instructions

Related

Can't find my package path in file explorer

My project package doesn't show in DDMS > File Explorer (I had selected my phone in window devices). I found that an error is shown in logcat, which says can't open file for reading.
Is it possible that I didn't install Eclipse properly? Before that, my project ran well and I could see the project path in the file explorer (under data>data>). After I had make few changes (I don't recall what changes I had made, too many), when doing another project, I uninstalled and reinstalled Eclipse, then this error appeared. I can't find ALL my project package in file explorer.
May I know what is the problem and how to solve it.
This is due to the permissions, DDMS will only show the files and folders he has enough access to reach.
You can change these permissions using the tool Android Debug Bridge (ADB).
ADB is located in the folder platform-tools in your SDK directory.
On Windows you can access shell by opening a command prompt, go to the SDB path and use the following command:
cd (...)\android-sdk\platform-tools
adb shell
Once the command shell is opened, you can enter the command su - root to get root access.
To change permissions on files and folders, you just need to use the command chmod.
EDIT: here is an example showing gow to change the right on a specific folder, and all its contents:
chmod -R [permissions] [dirname]
R means recursive, if you remove it, it will only change the permissions of the folder, not its contents.
In [permissions], put the permissions desired, a full access is for example 777.
In [dirname], just replace with your folder name.
Example:
chmod -R 777 new_folder
This command gives full access to the folder "new_folder" and its sub-folders.

Is it possible to run the .apk file on android/emulator?

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.

Can I export my .apk to my phone just for testing? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to install apk file on android phone?
I finished the app on eclipse and I tested it on AVD now I want to export it to my phone just for testing not for market how can I do that, thanks a lot !
Other suggestion:
Connect your phone to your computer.
Run your project and eclipse will deploy it to your phone.
Look in the bin directory inside your project folders. You can move it to your phone via dropbox or other means. I do it all the time.
You don't need to do the export wizard to just test. As long as you have the "allow unknown" checked in settings. Once the project has been built and run in the emulator there should be an apk file.
I used dropbox as my source control so my entire project is on dropbox which makes it very easy to test on phone. As long as you have dropbox installed on your phone you just navigate to the bin directory on your phone and download the apk from there.
There is an Export wizard, look in your AndroidManifest.xml file, from there you can create your apk, and then install it easily on your device.
Just place your APK file on your device.
connect your phone via USB
open a shell and move to the platform-tools folder
sudo ./adb kill-server
sudo ./adb start-server
run your application in Eclipse and go choose your device

In AVD emulator how to see sdcard folder and install an APK to the AVD?

I have created an Android emulator (Android Virtual Device), but I am unable to find out the SD card I have built during creation of this.
How can I find the SD card and its content and also how to install APK files to the AVD?
switch to DDMS perspective
select the emulator in devices list, whose sdcard you want to explore.
open File Explorer tab on right hand side.
expand tree structure. mnt/sdcard/
refer to image below
To install apk manually:
copy your apk to to sdk/platform-tools folder and run following command in the same folder
adb install apklocation.apk
I have used the following procedure.
Procedure to install the apk files in Android Emulator(AVD):
Check your installed directory(ex: C:\Program Files (x86)\Android\android-sdk\platform-tools), whether it has the adb.exe or not). If not present in this folder, then download the attachment here, extract the zip files. You will get adb files, copy and paste those three files inside tools folder
Run AVD manager from C:\Program Files (x86)\Android\android-sdk and start the Android Emulator.
Copy and paste the apk file inside the C:\Program Files (x86)\Android\android-sdk\platform-tools
Go to Start -> Run -> cmd
Type cd “C:\Program Files (x86)\Android\android-sdk\platform-tools”
Type adb install example.apk
After getting success command
Go to Application icon in Android emulator, we can see the your
application
These days the location of the emulated SD card is at /storage/emulated/0
On linux sdcard image is located in:
~/.android/avd/<avd name>.avd/sdcard.img
You can mount it for example with (assuming /mnt/sdcard is existing directory):
sudo mount sdcard.img -o loop /mnt/sdcard
To install apk file use adb:
adb install your_app.apk
DDMS is deprecated in android 3.0. "Device file explorer"can be used to browse files.
Drag & Drop
To install apk in avd, just manually drag and drop the apk file in the opened emulated device
The same if you want to copy a file to the sd card
if you are using Eclipse. You should switch to DDMS perspective from top-right corner there after selecting your device you can see folder tree. to install apk manually you can use adb command
adb install apklocation.apk
I have used the following procedure.
Android Studio 3.4.1
View>Tool Windows>Device File Explorer
//in linux
// in your home folder .android hidden folder is there go to that there you can find the avd folder open that and check your avd name that you created open that and you can see the sdcard.img that is your sdcard file.
//To install apk in linux
$adb install ./yourfolder/myapkfile.apk
Adding to the usefile DDMS/File Explorer solution, for those that don't know, if you want to read a file you need to select the "Pull File from Device" button on the file viewer toolbar. Unfortunately you can't just drag out, or double click to read.

how can I import .apk file of the downloaded file into Eclipse? Do we have this option?

I am newb To Android.I just to check out few applications in my Desktop and have downloaded some sample applications. However, they are in the format .apk.
Please let me know the procedure to import this file into Eclipse which helps me to run the application.
Regards,
Serenity.
If you want to test the downloaded *.apk try installing it in the emulator. Copy the APK file into platform-tools directory, navigate to platform-tools directory. Execute
adb install filename.apk
If you want to view the source code of the *.apk. Try this link How to View the Source Code of an Android *.apk
If you wanna run the application you don't have to import it into Eclipse but instead you have to install it on your phone.
If you wanna see the source code of the apk file, you need a decompiler. There are some available in the Internet, however, all of them I have seen doesn't work 100% (e.g. they can extract the resources but not the *.java files, and so on)...
But you have to note that using decompilers could not be legal in some cases
You cannot "import" them to Eclipse as they are binary files. But, you can test the applications using the Android Virtual Device:
http://developer.android.com/guide/developing/tools/avd.html
In order to use it you will have to install the Android SDK and configure a Virtual Device:
http://developer.android.com/sdk/index.html
Once you have installed and configured the virtual device, you just have to install you aplications using the adb tool:
adb install applicacion.apk
Also, if you are using WinRAR or other zipping programmes, right click on the .apk file with your mouse and open with winrar/winzip/e.t.c. then surf to the .xml files then edit them via notepad easily.
If adb complains you have multiple devices, do
adb devices
Notice the serial number of the one you want, and then
adb -s SERIAL -r filename.apk
File -> Import -> Android Code into Workspace -> (Select Root Directory (folder) of the Application you are importing) -> Check the (Copy projects into workspace [checkbox]) -> Click Finish [En Twitter puedes preguntar][DS]
If you want to test the downloaded *.apk in the Emulator --> install it in the emulator.
How to install .apk file into Emulator?
Ans: Copy the *.apk file into SDK->platform-tools directory (where you'll find adb.exe file),
navigate to that directory through command line on your windows PC.
And then Execute:-
adb install filename.apk
If you want to view the source code of the *.apk.
Try this link How to View the Source Code of an Android *.apk
Compress .apk with winrar, open it in winrar and click on apk file. It will show the content just click on extract. Now you have a complete directory structure of a source file. Try to repeat the import steps as suggested above.

Categories

Resources