If nothing is changed since last compile and run, and then I hit run again (green start button), it complies and then run.
How can I make it run directly without compiling the same thing?
I might be wrong, I don't think but it's possible when you pass by Android Studio, but by using the build apk and install it with Android Debug Bridge (ADB), you should get the desired behaviour.
When the project compiles, AS creates an output apk. Usually, this should be named app-debug.apk and located in build/outputs/apk/ folder:
Your .apk file (signed with either a release or debug key) is in your module build/ directory after you build your application.
cf. Running on emulator
By using adb, you'll be able to install this apk previously generated (and I believe, without compiling again) on the device with the command install:
$ adb install -r path/to/app-debug.apk
Once installed, you should retrive the command to launch your application. A little research bring me to "How to start an Android application from the command line?":
$ adb shell
$ adb am start -n my.package.name/my.package.name.MyActivity
And then, you could combined them on same line to launch the apk just right after its installation. This looks like:
$ adb install -r path/to/app-debug.apk && adb shell am start -n my.package.name/my.package.name.MyActivity
Therefore, you application will run without compiling.
First try right click on the project and then select Run As Android Application. This will change you app default run configuration.
If this does't work then try to change it's run configuration from right click on project in project explorer and select Run as -> Run configurations.
Always run your project if you have opened that projects java class tab in workplace. You cannot run your project directly by clicking Green play button if you opened a XML file of that project. However you can run a project if you have opened manifesto of that project.
Related
I'm building an Xamarin android admin app meaning that the app will be the device admin but in order to be able to uninstall the app while developing I need to add to the android manifest android:testOnly="true"
but then it fails at deployment I get the following error
Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
and to avoid that error I need to pass an install flag with adb as written this stack overflow answer
how do I do that in VS.
First of all, please archive your application then export the xxx.apk file. Note: when you archive your application, please notice following settings.
unselect following settings
select following settings.
For example, I archive my application to root path of F desk like following screenshot.
Then, open the adb command to click the icon like following screenshot.
Enter the F: in the adb console. Then enter the adb install -t -r com.companyname.app25.apk like following screenshot(please make sure your android emulator is running).
In the end, you will found your apk file was installed.
I used ant to build my Eclipse project from the command line in a debug configuration. (Eclipse Luna and Android NDK-R10d is broken, so I can't use Eclipse any longer. Confer, Eclipse/ADT plugin cannot locate symbols for r10d NDK).
I then performed an install using adb:
<Project Directory>$ adb install bin/AndroidPrng-debug.apk
When I rummage for the program on the device in Apps, the program is not offered. When I attempt to search for it by name on the device (AndroidPrng and com.example.prng), I'm provided with useless web search results. When I go to Settings → Apps, the app is shown under the Downloaded tab (it shows the name as com.example.prng). It has the familiar Force Stop and Uninstall.
I have DDMS running and waiting to capture LogCat output from the program. But even though the app is on the device, I cannot figure out how to run it.
How do I run and debug the app when it does not show up under Apps?
Assuming that your app do have an Activity from where you can navigate into other parts of your app.
Try using below command:
$ adb shell am start -n com.example.yourpackagename/.YourMainActivity
or $ adb shell am start -n com.package.yourpackagename/com.example.yourpackagename.YourMainActivity
This am start command, is a command-line interface to the ActivityManager.
Does anyone know the way or the trick to make signed APK and install it on device from inside the IDE? Just like when we sign the app via debug key and then automatically install it on the device from the IDE.
When I test in-app and have to make multiple changes, it's slowing me down the fact that each time I have to install the APK by coping it onto the device or via console.
You can have an artifact that will build a signed APK.
Then create an External Tool (batch file) that will upload the artifact to the device using adb install command. Optionally add the code to start the main activity. My install.bat looks like this:
adb install -r bin\ClockSync.apk
adb shell am start -n "ru.org.amip.ClockSync/ru.org.amip.ClockSync.view.Main"
Modify the commands if you want to deploy to the specific emulator/device.
External tool configuration is pretty straightforward, just run the bat file.
Now you can create a Run configuration with Before Launch section set to build the signed APK artifact and start the external tool to deploy and run it.
EDITED by sandalone
This approach is for IntelliJ IDEA users. After you set it all up, just launch the app as usual Shift + F10 and the app will be built as signed APK, installed on the device and started.
Since I am on Linux, I made the script install.sh with the following content
adb -s DEVICE_ID install -r ./com.package.name.apk
adb shell am start -n "com.package.name/com.package.name.MainActivity"
made it executable and this was it. Of course, the script should be located in the same place as APK - otherwise fix the path accordingly.
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
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