I have a question about the Android virtual device(avd)... as what you already know, that you can test your android application through avd in eclipse, and i'm getting a boring repeted thing with that.
each time I want to test my application and when I make a small change to my application, I have to run the avd again and wait for a long time till the application run(switch the device on and wait for the system to boot and then wait for the application to start,this takes approx. 15 sec)... as I said, each time I make whatever change to the program I have to go through these boaring time consuming loop :( ...
So, is there is a way to avoid these issue, and makes the avd run only for the first time and any changes can take effect quickly and only needed to restart the application without needed to stop and run the project again ??
I hope there is a way for that.
When you're done with a debug cycle, do you close the AVD? If you keep the AVD running, it should do exactly what you're describing.
If that doesn't work for you, a look at your application manifest may be needed.
Simply don't quit the emulator. Leave it running, hit Run (or Debug) in Eclipse, and if anything changed, the program will be uploaded to the emulator again.
Don't close the emulator. Keep it running and click debug again, it will run fast since it won't reboot. (The emulator will just re-install the app instead).
Related
Dears, can you help me with my problem as it's my first time using this software, and I wanted to download my application on my phone, but it kept showing some errors. I have read some of the familiar cases but couldn't figure it out. so can you help me, please !
My code, and I've highlighted the error that keeps showing up
This is what appears on my phone when i run the program
This looks OK, debugging always slows down the app, and you will have to wait for a bit. You can go faster using some of the available emulator to test it on your computer. Try genymotion, also you can even try bluestacks.
At first, I'm new in programming of Android. And I have a problem/question.
Every Time i will click the 'Run' button to build and run my application on my device, my changes in the activity doesn't update/apply on device.
Is Anybody the, who know what i mean and know how to fix my problem.
I tried to find something in the preferences but i haven't found something.
At the moment i have to rebuild every time before run but this isn't a very nice way i think. There should be a better one.
Thank you for your answers.
Greetings
If you are using Instant Run, this is probably whats causing the problem - it doesnt recognise the changes you've made (at least that was the cause when I first had this problem). Just rebuild or clean your Project as already suggested - this will cause Instant Run to fully reinstall your application and not only install the new Patches. For me it occurrs quite often, I don't really see a pattern behind it but it's usually when I go to edit a completely different file/class, or when starting a new programming session.
Goto Build > Rebuild Project after that click Run again.
If it does not still updates your app I suggest to uninstall the app on the phone or in your emulator then Run again so a that a fresh APK copy will be installed.
Note: This is an odd thing when you are just running again without changing anything in your code.
The content should change, but I've noticed that with the latest instant run method, asset files typically don't get updated when you run it again. You could try setting up your preferences again and making sure you have updated your gradle, but if it's not updating you can simply kill the app before you run it again, either with the red stop button on Android Studio or though your phone.
I want to install a monitoring system on a computer (the program is a jar file) and run it on start up every time any user logs on. However, I don't want the user to be able to terminate it since then it won't be able to be monitored any longer.
We have tried several ways:
Installing it as a service - the problem here is that our program doesn't work any longer; it can't connect to the computer that's monitoring it. We used "Yet Another Java Service Wrapper" for this, and looked into some other wrappers as well that could help us install it as a service.
Running the program on start up (using the folder startup), but not giving the basic user the privileges to edit/delete/mess around with the files. However, this seems to slow the whole computer down? This doesn't happen when we run the bat file executing the jar directly. Another issue with this is that the user can just go to the task manager and kill the java process.
We tried a variation of the previous one to solve the issue of the process being killed, by having another process. One will spawn the other and these 2 processes will keep tabs on each other. If one terminates, the other detects it and runs it to start it up again. Although it can have issues if the user is fast enough in killing both processes before either is respawned again, the bigger issue is that it sometimes has problems with connecting to other computers. We didn't have this problem when it was just 1 jar.
Does anyone have any idea on how these problems can be solved?
The context here is windows, but if you have suggestions for linux and mac that would be nice too!
Way to go is to run the program as a service. You should investigate any trouble between your application and your system's firewall. If you have windows firewall activated, you should add an exception for java.exe or javaw.exe.
In order to give elevated privileges to your program, you can set the service to run as another user. You can do this from the "Log on" tab in the service properties.
You'll want to have the program started under a user with elevated permissions. On WIndows this would the the Administrator, linux would use root. On Windows, its likely that you will need to start it as a service. But I really don't know why that would hinder the network communications.
I'm using Eclipse and the Android plug-in for my Android phone development. I just worked through my first application from the "Busy Coder's" book and I'm having a persistent problem. Every time I run the example Java application, using a properly configured Android Run configuration that references the example project, the emulator starts (if not already started) and the application is seemingly deployed to the emulator. However, what shows on the emulator is not a reflection of the application's current state. Specifically, the example application I typed up should display the current time and then every time you click on the main app view area it should update the current time (via a Button object instance created in the constructor that has an onClick() handler). Instead, I see "Hello World" and clicking on the main view area does nothing.
It's as if some old copy of the test application is being pulled up. I even hunted down the strings XML file for the project and I did find a string declaration that was defined to "Hello World". I then changed that string to something else, rebuilt the project, and re-launched the application. But I still got the same "Hello World" display and still do not get any response when clicking on the main view area. I even tried shutting down Eclipse and the emulator and nothing changed, and also cleaning the project before a test run.
So, what are the usual mistakes a newbie makes that could cause this situation?
-- roschler
This happens to me occasionally but it is usually fixed by deleting the application from within the emulator UI.
After deleting the application from the emulator and reinstalling it I can launch the application using "Run". After this the application is updated every time the "Run" button is used.
Check the console to see if the activity is actually being installed and launched rather than being brought to the front when you "Run" the app.
If you launch in debug mode, the new build will always be installed in the emulator/device.
However, if you launch in run mode, you need to increase the version number in AndroidManifest.xml, or the new version won't always get installed.
Please see Android: Eclipse doesn't pushed new version of app to emulator from earlier today.
Hope this helps,
Phil Lello
By far the most common reason this happens to me is that I failed to notice that there was an error compiling the application so it didn't push the new version. Especially when my package explorer is obscured so I don't notice the red X.
Edit: one other reason it often happens to me is I have more than one emulator running or my phone or tablet plugged, and I accidently install the latest version to the wrong device without paying attention.
I open the manifest file in Eclipse, "touch" it by deleting and undeleting something, save it. This seems to refresh the APK for me.
I'm new to Java (come from C++/.NET background) and am experiencing very strange error. I am developing w/ Eclipse IDE on Windows XP on my local desktop. It seems that for some reason, an older (and of course buggier) instance of my application stays running for some very odd reason which I cannot understand.
Even when I close eclipse, this old version of my application is running in the background. So unless I reboot, when I try to test new version of the code, this 'old, rogue instance' is fighting for the resources that are used (files on a share) with the newer (hopfully less buggy) version of the code.
Has anyone experienced this? Does the JVM cache old versions of your Java application for some reason? What am I missing here? When I reboot my machine, the instance finally dies...
I was ripping my hair out trying to figure out why the new version of my code still had the same old bug until I realized this was happening... shrug
Thanks for any help!
Do you by chance either run your program multiple times, or have forgotten to close one instance of it prior to re-running it from Eclipse?
One thing, that is not very obvious when using Eclipse, is that it allows to run any number of instances of Java programs simultaneously. When you have the Console view active, you have the option to terminate the latest launch.
To switch the console to a different launch (if there are multiple running) you can select from a list, by pressing the "Display Selected Console" icon, which is the monitor icon to the top-right in the Console view.
You can also remove any and all terminated launch console outputs from the Console view, by pressing "Remove All Terminated Launches", if every launch have been terminated it should now display "No consoles to display at this time", otherwise the next-newest running launch will be brought to the top.
If this isn't the problem, and indeed Eclipse have lost track of a launch (which is quite rare, but can happen - especially if you spawn sub processes yourself), you can safely terminate any run-amock java.exe process from the Task Manager, as Eclipse runs wrapped in a Windows executable on the Windows platform.
Java applications run under "java.exe", so you can look for that in the task list. Sadly, if several Java applications are running at the same time, it's hard to tell which is which.
I'm not terribly familiar with Eclipse, but it seems like Eclipse should tell your old version to terminate when you close Eclipse. The JVM doesn't cache past versions.
Hope this helps.
I had a problem like this as well. I would try to run the program after making changes, and it would run the older version of it, and still report errors and stop on lines that I had even commented out. I tried micdah's solution, but there were no java.exe processes in Task Manager. I solved the problem by killing the Eclipse process from the Task Manager, which closed the program without saving Eclipse Workspace settings. When I relaunched, everything I had saved in the .java files launched normally.
Could be a bug in Eclipse. Could be some code in your application that's spawning a new process. Impossible to tell from over here.
If you haven't already, check out the jps tool, which is included with the regular JDK. It might make it easier to diagnose the problem.