Update apk file after changes to source - Android Eclipse - android

Is there a way I can just update the apk file after making changes to the android source file in eclipse. I want to be able to do this without actually pressing the Run button in eclipse.
The reason I want this is because - I usually keep the emulator open in the background (since booting it up everytime takes too much time on my slow computer). And when I run the program after a previous run, eclipse just seems to hang up - even after I have stopped the app in the emulator.
So I decided to use the adb install command-line program to install on the emulator, but am unable to get the apk file updated without actually pressing on the run button in eclipse.

Actually, the Eclipse ADT plugin works like you want it to work. Everybody just run emulator once and then pressing RUN button update the application. If you have problems with this post the logcat during the run of your application.

You always can check the Build Automatically option in the Project menu option in Eclipse. Or you can Project->Clean your code, sometimes Eclipse get stuck trying to refresh all projects and dependencies.

You can un-install apk package with command line----
in linux os example:- adb shell pm uninstall -k <package name>
You can leave -k if you don't want to delete data and cache. If this command is failed then use emulator;
open settings in emulator -> apps -> your app and then stop it or un-install with emulator and it is more easy. Options are depend on emulator device.

Related

Android: app shut down in debug process

This is an issue with Android Studio settings or something else I don't know? When I debug the app and at some debug breakpoint(Breakpoint is not fixed for every shut down it varies every time) it shut downs the app and never shows in debugging choose process dialog. To get it again in the debug process I need to run the app again.
Why this all is happening, Is there any Android Studio settings required to stop this all happen?
My Android Studio version is 2.2.1. Any help will be appreciated.
adb install -r applicationname.apk -- the -r option says to replace the existing app. If you don't use -r, you must increase the version in your manifest in order to install over the top of the previous one.
(or)
adb - How to reinstall an app, without retaining the data?

Cordova emulator not starting

I am trying to use the Android emulator to install an app on it.
Unfortunately the emulator is never starting up. I use the following
command in my cordova project:
cordova emulate android
The last output I get from console is:
Waiting for emulator...
But the emulator does never start (I waited 45 minutes now).
The path variables are all correctly set and I can start the
emulator using Eclipse or Android studio but not using the
command from cordova.
Any hints?
If you can start the emulator through android studio, then as a work around start the emulator outside and run the command
cordova run android
It will deploy your app in the already running emulator.
Check emulator path settings
https://cordova.apache.org/docs/en/4.0.0/guide_platforms_android_index.md.html
If not able to execute then do :
use the alternate shell interface:
$ /path/to/project/cordova/run --emulator
Instead of relying on whichever emulator is currently enabled within the SDK, you can refer to each by the names you supply:
$ /path/to/project/cordova/run --target=NAME
Check the documentation above and see whether your PC supports virtualization or not.
I was getting the same issue, I resolved it by:
Open Android device manager, click on window -> Android Virtual Device Manager
There you will see listing of all the Android Virtual Devices, if you see any device with repairable icon on it, just click on repair and then try. It works.
I had the same problem. Though cordova started the emulator, the command line kept on saying 'Waiting for emulator...' forever.
The trick is, before running the command:
cordova run android
make sure you navigate into the android platform folder. That is, don't run the command from within the
/project folder
but instead from within
/project/platforms/android folder
That will launch your application in the Android emulator

Android Studio hangs / Freezes when project build fails

I am experiencing a very wired problem since this evening.
If I have any errors in my android project, and build is failed, then my Android studio gets frozen / stuck. I cant do anything but kill the Android studio application.
Even if I open the same project next time, gradle will try to build and freezes again. [Please find attached screen shot]
Only solution I could find is .... I have to find what exactly cause the "build fail" and I will have to resolve the issue using some other editor, and then my android studio will start working.
Thing is it was working without any issues till this evening; and suddenly broken down. Any one else having the same issue ??
-n
If you are using Android Studio v1.2.1.1 or newer and you are using Macbook, I've recently seen that if your device is connected to your laptop (by usb have no idea about over the wifi) and you sleep your laptop then login again, Android Studio hang. Therefore, you need to unplug usb cable then you should see Android studio is happy and then reconnect your usb cable.
Open your terminal and reset adb:
adb kill-server
adb start-server
This is how I solved the same problem:
Go to your project directory using your terminal
run ./gradlew (or gradlew.bat) assembleDebug
Fix the problems reported by gradle
Restart android studio and the problem is gone
Based on barbarian's answer I did this on my Mac:
start a terminal
chmod +x gradlew
./gradlew
./gradlew build
This last step showed an error in my xml file, indicating that I used unescaped single quotes. Fixing that solved the hangup.
Well, I uninstalled android studio and installed it again, and now the problem has gone away.
I still wonder how in the world it broke in the first place.
In case some one else is facing the same issue, try reinstalling your studio.
In case if you are using Mac osx refer How to completely uninstall Android Studio? to uninstall Android studio properly; Because only deleting App will not completely uninstall it.
In my case the same thing happened, after I had added image-resources with dashes in the filename.
I manually deleted them, renamed them, and added them with underscores in the name, and Android Studio worked normally again.
(I am not sure the dashes were the reason, why should they, but doing the above fixed it.)
#Hesam's answer doesn't work for me. Using OSX and AS 1.2.1.1, my building stuck in 'Scanning files to index' and I cannot solve it even after restarted my Macbook. Below work for me:
Shut down Android Studio (force to kill or just unplug the usb you will be good to go)
Go to the directory of AndroidStudioProjects and move the application directory out to some other location (outside AndroidStudioProjects).
Restart the android studio, now you will be shown the screen asking you whether you want to start a new project or open an old one.
Again paste the folder you have cut and kept aside in step 2 back to AndroidStudioProjects directory.
In the android studio prompt, select open existing project and select the directory you have now just pasted to AndroidStudioProjects.
It should work for my case.

Android emulator not installing new apk

I recently started learning how to develop android apps. One annoyance I'm facing is that after a successful build of my code, after I modify it and make some changes and save it, the emulator won't load the new code until I close and open the emulator like 2 or 3 times. It says something along the lines of installing blahblahblah.apk in the console, and then after that the new code finally runs on the emulator. Until then, it keeps running the last successful build.
Does anyone know how to either:
Make the emulator install the new apk without requiring that I restart it several times
Make the emulator load faster (I already tried increasing the RAM)
I'm using the version of eclipse that came with the ADT bundle provided by Android.
To make your emulator fast just do following.
download intel-hardware-accelerated-execution-manager. from here.
http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager.
install it in your computer.
after that intel atom system images in android SDK.
after that create new emulator and select intel atom in cpu option.that make ur emulator fast.
Try this ,
Run As > Run Configuration
.. Android > Brows project which you want to Run.
.. Target > Enable "Always Prompt to pick device."
.. Common > Check both "Run & Debug".
And along with that Enable (Check) Wipe User data of your virtual device so that will uninstall older APK and install new one. Because some time emulator use older garbage reference.
Instead of closing and opening the emulator(I know it is time consuming), you can
use the "reset adb" under the devices window
to reset your emulator(it is a matter of seconds.)
Steps to speed up emulator (atleast to a small extend):
Increase your emulator ram size. Use a small screen sized
emulator.(Makes the rendering process on arm faster).
You can clear cache/data per application from settings (Applications -> manage applications). This of course only clears data that your application is creating. You can also uninstall your application from there which will cause everything to be cleared. Then you can run your application without starting emulator again.
firstly go to project->
select build automatically
if it is not working then
open the command prmt and go to the path of your sdk like-
E:\param\android-sdk\android-sdk\platform-tools
write commnd adb kill-server
then again write command adb start-server
this will help you

Android, ant, and Eclipse: it never reinstalls the APK on the emulator after rebuilding. How can I fix this?

I have been developing on Android with Eclipse for a while, and I recently switched over to using Ant for my build system. This gives me a number of useful advantages, but it seems to really badly break Eclipse's behavior with respect to building and the emulator.
My biggest problem right now is that, if I change something in my code and hit the "Run" or "Debug" buttons, it rebuilds the app like it's supposed to, but when it comes time to install the app and run it, I get the dreaded "Application already deployed. No need to reinstall." message, and it refuses to install it. Even if I do a "clean" and rebuild my app from scratch, it still doesn't recognize it as newer than the one installed on the emulator.
Of course, I can uninstall the app from my emulator first, but that's a huge PITA, because my app involves setting up a user account after initial install, and I don't want to have to do that every time I am testing a change. I can also force install from the command line through "adb -e install -r ...". That's what I'm doing now, but it's an extra step that shouldn't be necessary. I would really like to be able to take advantage of the "I" part of my IDE and actually compile, run, and install from it the way I am supposed to be able to.
How does the Android SDK in Eclipse decide whether the app needs to be reinstalled? Is there a timestamp on some particular file that it looks at? Is there a way I can force it to install every time?
There has to be a solution to this problem.
This works fine in my eclipse, and it always had. So I would suggest:
reinstall ADT plugin
reinstall eclipse altogether.
Or you can workaround this issue by adding extra step to your project with "adb -e install -r ..." command line (using ant build script).

Categories

Resources