how can i get apk file path from java application? - android

how can i get apk file path from my java application?
I have apk file in android device and i want to find the path for same apk using java application.Is it possible to get using ADB command?
thank you.

By default android has an app called dev tools.
Launch the dev tools . so It is as follows..
Dev Tools --> Package Browser --> Click on the app
Thats all u will get path of apk
or Install apk on the emulator.And Android Emulator has an app called dev tools.
and do in the same manner as mentioned above ..

Try the following from the adb shell
$ adb shell pm list packages -f

Related

Where does Android app package gets installed on phone

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

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.

Installing an apk on android emulator on Mac OS

I tried following these steps(from here):
go to sdk folder, then go to tools.
copy your apk file inside the tool directory
./emulator -avd myEmulator
to run the emulator on mac
./adb install myApp.apk
to install app on the emulator
But when I run "./emulator -avd phoneEmulator" (phoneEmulator is the name of my emulator)
it just displays:
My-MacBook-Pro:tools myName$ ./emulator -avd phoneEmulator
2012-07-30 22:44:33.377 emulator-arm[2859:80b] Warning once: This application, or a
library it uses, is using NSQuickDrawView, which has been deprecated.
Apps should cease use of QuickDraw and move to Quartz.
It's as if that command is never returning.
If I can't input the 2nd command ./adb install myApp.apk in that window, where do I call it?
Open Terminal
go to android-sdk-mac\platform-tools
type ./adb install myApp.apk
You can work around by:
You have a *.apk file with you if you don't have, download it.
Open Android Studio and Run the emulator.
Open the finder and go to the location which contains your *.apk file.
Drag that *.apk and drop into the emulator and it will ask for confirmation after your confirmation it will install the *.apk in the emulator.
You can find it in application menu once installation succeeds.
First of all, you SHOULD NOT copy APKs to the tools or any other SDK directory.
Do not cd to the SDK directories, just add them to the PATH environment var or use their absolute path in command lines.
Then, if you want to run the emulator and then execute command from the same terminal, send the process to background (&):
$ export PATH=$PATH:/path/to/sdk/tools:path/to/sdk/platform-tools
$ emulator -avd myEmulator &
$ adb install /path/to/my.apk
You can work around by:
Upload yourapp.apk to internet. I.e: yourhost.com/yourapp.apk
Run emulator
Open internet browser on your emulator, visit link yourhost.com/yourapp.apk
Download and install
adb can be run from a seperate terminal once this emulator boots up.
May Be, Useful to all the command in MAC OS Terminal
Am I the only one whose apps install in the emulator when I run them as Android Application from eclipse?
I mean - why go though the trouble of adb when you could just use eclipse? (unless you have something against eclipse!)
Try this app. It will install the apk by just double clicking on it after you create an association to .apk files. It's all explained in the github source.
Alternatively You can use 'adb install' command as follows. "adbinstall/filename.apk"
ex. adb install /Users/manojclinberg/Downloads/ad3e0e46-d716-4fa9-b603-b8db3accf260.apk

How can I install adobe flash on the android emulator

I want to use Adobe Flash in the development of Android applications. But how do I install flash on the emulator so that I can test my software with flash?
To install the AIR runtime on the emulator:
adb -e install -r Runtime_Emulator_Froyo_20100930.apk
from this site:
http://flashsimulations.com/2010/10/19/developing-android-applications-with-adobe-air/
download the adodeflash player file(.apk) and install using the command adb install filename /sdcard/
I tried this using comadobeflashplayer-1.apk, but it crashes the emulator browser. I was able to uninstall thanks to this helpful link:
http://forum.androidcentral.com/lg-optimus-s/43187-installing-flash-10-1-optimus-s.html
I did not put it on the sdcard (which is the -s option)
There might be some configuration option for the avd that allows it to run, but that's speculation.
Install flash procedure for AVD
Download appropriate flash apk file from : http://helpx.adobe.com/flash-player/kb/archived-flash-player-versions.html#flash_player_archives
Make sure yours PATH environment includes path to /SDK/platforms-tools (or wherever your adb program is)
Then open commandline (terminal or cmd.exe), and run following command
adb install FLASH.APK
This install flash APK to android virtual machine (as any other APK application package)
But let me warn you, FLASH does not work in webView, and I tried all answers from this portal.
In the Android browser, browse to http://get.adobe.com/flashplayer and it should redirect you to the Android Flash install.

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