Debugging Genymotion in Eclipse on Windows 7 - android

I've been using the Genymotion Android emulator for 2 weeks now. So far all was good, I was able to debug and everything was working fine (and in a pretty fast way too).
Suddenly the debugger went crazy yesterday: it jumps over certain lines of code, does not execute certain methods, shows that an obj instance is not null (on mouse over) but does not execute if (obj != null) code blocks which follow, etc. etc.
Is there any solution for this?
In fact, I think it's behaving the same way with the standard Android emulator too. And that also started yesterday. So I am just puzzled what I can do in order to fix this weird problem and continue working normally.
Needless to say I cleaned and rebuilt my project a few times in Eclipse. Rebooted my PC too. Nothing helps for now.

I can't be sure that this is the issue, but I have experienced a weird debugging behavior when I had an interface with two method with the same generic type name but different signatures, e.g.:
public <T extends Something1> void method1(T t){...}
public <T extends Something2> void method2(T t){...}
The issues I've encountered were:
I could not evaluate any expression.
Count not step in or over, only run... till the next breakpoint.
I'm sure there were other things but I've looked over them as I was only trying to get things done :|
For some reason this is known issue in Eclipse and has not been resolved for the last few years...
So the real solution for this is actually to rename one (or both) of the generic param names to so:
public <T1 extends Something1> void method1(T1 t){...}
public <T2 extends Something2> void method2(T2 t){...}
Surprisingly this solved the bug for me which drove me nuts for a real long time!
I hope this is the issue :)

this could be not related to the emulator then
as standard emulator is not working fine too.
this could be some miss-sync between the source code and the compilation result
so the debugger starts acting crazy
i had this one time,
the sol was related to the option add line number attributes to generated class files (used by the debugger)
to find that option:
1- right click on the project you have trouble with
2- select properties
3- from left pane, select java Compiler
4- at lower part of right pane, under Classfile Generation:
here you may have 2 cases:
1- that option is NOT checked, so just check it, click apply, and a clean-build might be good
2- if that option is CHECKED, the uncheck it, click apply, close the dialog, clean the project, and buil.
THEN re-open the dialog and navigate to that option, CHECK it, click apply, then close dialog
clean project and build.
Note: it might be better while doing this to unselect Build Automatically option from Window menu
then re-enable it once you have done above steps.
good luck

Related

Can I make Android Studio show errors immediately, like Eclipse used to do?

There is one thing I really miss about Eclipse and it was that if I commented out a public field, for instance, the project immediately turned red and all the classes that use this field, also turn red, so I know what I broke.
In Android Studio, I comment out a public field and nothing changes, and if I want to find which are the affected classes I either have to try to remember where I used it, or run a rebuild, wait for a minute, until the error appears.
Can I make Android Studio do this kind of check in real time like Eclipse did?
It works in Android Studio as well. But only for the current visible class.
Make sure Power Save Mode is not enabled. You can uncheck it at 'File > Power Save Mode'

Strange Lint-errors in Android project

since I updated my Android SDK today I get some strange Lint errors in my project. The activity contains amongst others a textview. Everything works fine, but if I want to change the text size of the view within the code with .setTextSize(float size), I get in other lines (and also other independent methods) errors that a call requires a certain API level. But that are calls like string.isEmpty(), which is available since API level 1.
What am I missing? And I know, I can set the text size also in the xml-file, but I want to change it during runtime.
Any ideas?
Thanks!
Best regards
Tobi
I think I got into something similar some time ago (nonsense Lint errors)...
Are you working with Eclipse?
If so, you can try the following:
Restart Eclipse
Clean your project (Project->clean...)
Click the button "Runs Android Lint..." (it's in the toolbar, between the "Virtual device manager" and the "new project wizard")
I don't remember exactly what did I do to solve the problem, I hope it works though
Good luck!
With the latest release, I've had a few times where the lint errors were just incorrect. (missing semicolon on a line with a semicolon, etc).
In such cases, you can right-click on lint error warning, or on the numberings on the left side, and select "Clear All Lint Markers".
This will allow you to compile the file once, and if that works, Lint seems to start acting normally again.

Android application problems in Eclipse

I'm a .NET developer but I like JAVA so in my free time I play around with that. I don't normally use Eclipse but I installed the ADT eclipse plugin and Andriod SDK and I started learning and I made a new project with a TableLayout and it kinda looks good, and it runs ok on the emulator.
However... there a few things that drive me absolutely catatonic and perhaps I am doing something wrong so please help me out.
Firstly, if I change the main.xml file in whatever way, even by adding what is supposedly a correct parameter, it will start freaking out and will generate an error that just says "error" without specifying what that is, it will then generate a main.out.xml and then report an error that the main.out.xml is empty. It later won't let me delete that and will start generating a main.out.out.xml and so forth, even after I correct that original xml that caused the error.
The only way to get things going is to delete the bin folder, restart Eclipse, delete all the out xml files and then sometimes it will run the application or some other times it will start generating those 'out' files again and the loop goes on.
That way it takes hours to run a simple app even one without errors that used to run before.
Surely that was NOT how they intended it to work, is it??
Also.. there is no "Rebuild" button that will flush all files out automatically, or is it hidden somewhere? I am tired of manually deleting those automatically generated files and the build folder and all those out.xml files.
Also, while I'm at it, I also want to point out that the designer view sometimes disappears and there is nothing on earth that will bring it back, the only way is to create a new project and copy the main.xml to it and then it shows up again. Another bug?
I have the latest eclipse version:
Version: Indigo Service Release 2
Build id: 20120216-1857
If you have any clues how to get this to work, I will appreciate it!
Many thanks in advance
When you click the Run button with an XML file selected, Eclipse is running an XSL Transformation on that XML and producing the .out.xml file as the result. This is a feature of the Eclipse Web Tools feature, which you'll have if you installed the Eclipse for Java EE Developers package (it may be included in other packages, too).
As others have said above in the comments, to run your Android app, select the Project, right-click, and choose Run As > Android App. Once you've done that once, it will create a Launch Configuration that you can launch from the Run or Debug toolbar buttons (pressing the small down-arrow on the Run or Debug buttons brings up a list of Launch Configurations that you can select from, as well as an option to manage them).
There is a Preference that will make Eclipse always launch the last thing you ran or debugged, instead of trying to be smart about what is currently selected. Open the Preferences and navigate to Run/Debug > Launching; there you'll find the option under Launch Operation at the bottom of the window.

Logcat not displaying my log calls

I'm a total noob at Android programming, and wanted to learn how to debug my apps. I can't seem to have my Log.i|d|v calls displayed in the LogCat.
Here's the code that I'm using. As you can see I have defined a LOG_TAG constant, but can't seem to find it in the LogCat. I have also imported android.util.Log AND I have made sure that in my AndroidManifest I have "debuggable" set to TRUE.
I have also checked http://developer.android.com/reference/android/util/Log.html w/o any luck resolving this issue.
What am I doing wrong? Am I even looking in the right place? I've tried using the DDMS and Debug perspective as well w/o any luck. Any help to this noob would be greatly appreciated. Thanks.
My environment:
Windows XP
IDE = Eclipse Version: 3.6.1, Build id: M20100909-0800
Emulator = having it point to android sdk 2.1 api 7
//very basic HELLO World code with a couple of Log.i calls
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class debugger extends Activity {
private static final String LOG_TAG = "debugger";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
Log.i(LOG_TAG, "line 13");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(LOG_TAG, "CREATING NOW");
}
}
When using Eclipse, in the DDMS perspective, make sure the correct device (propably emulator-xxxx) is selected and highlighted. Only then will you get the logcat output in the logcat view.
Also, the Android plugin is a bit quircky, and sometimes only shows the last line in the logcat view. If this happens, try to clear the log. After that, you should get all the log entries again (works for me anyway).
If all else fails:
I did all the above things and couldn't figure out what was wrong,
Test with:
adb logcat
to figure out that my entries were infact in logcat, but twas adt's quirks.
Fix:
Restart eclipse
This was the only thing that fixed it.
I've had the same problem using Android Studio and managed to get around by selecting No Filters in the select box in the top right corner of LogCat. By doing this I started receiving everything Android logs in the background into LogCat including my missing Log calls.
Restart Eclipse and check log cat will be displayed.
I figured out I was automatically importing com.sileria.Log (from some library project) instead of android.util.Log, where the latter was the correct one. Check your imports as well.
I've noticed that Eclipse will sometimes throw an exception upon starting an Android app, then LogCat stops updating. I've corrected that by simply restarting Eclipse. I'm not sure if you've tried that and I know it's far from an optimal solution, but I suspect that the Eclipse plugin still has a few bugs to iron out.
Easiest way:
Check in your logcat window - TOP RIGHT corner PAUSE button || (Pause receiving new logcat messages)
Few clicks + eventually restart eclipse (usually works in my case)
I needed to restart the adb service with the command adb usb
Prior to this I was getting all logging and able to debug, but wasn't getting my own log lines (yes, I was getting system logging associated with my application).
There are a number of reasons why you might not see logs, most of which are listed below. Here are some steps to check most reasons:
Make sure you don't have 'android:debuggable="false"' in your
AndroidManifest.xml
Make sure your logcat isn't paused and make sure you are scrolled to the bottom
Your filters should either be 'no filters' or your current app
You have the correct device selected in your logcat devices list
If you're not getting any messages, try restarting adb. You can do that from Android Studio by clicking on the 'restart' icon, it's right after the print icon for logcat and it looks like a green curved arrow coming out of a box. If you don't see it, mouse over the '>>' that continues the icon menu when the logcat is too small.
QUICK FIX.
Just restart the eclipse
Works Perfect.
On Android Studio:
Click on the green arrow pointing to the right to restart the logging; if it is not visible, click on the >> icons to locate it.
I'm a newb as well to Android-Eclipse. Here's what it took for me to get LogCat messages to display in Eclipse:
1: add this to the class in which the logcat message is called:
private static final String TAG = "MyActivity"; (per the documentation here)
2: add this Log.i(TAG, "inLayout - finished"); when you where you want to display a message
If the above doesn't work, then shutdonw Eclipse and restart it and rerun your project.
It should then work.
There is one more thing to watch for:
On the top right side of the logcat there is a dropdown table for filtering messages by type. Make sure it's on the level you are looking for (if it will be on the assert level, it will likely leave your logcat empty).
Please go to Task Manager and kill the adb.exe process. Restart your eclipse again.
or
try adb kill-server and then adb start-server command.
Probably it's not be correct, and a little bit longer, but I solved this problem (Android Studio) by using this:
System.out.println("Some text here");
Like this:
try {
...code here...
} catch(Exception e) {
System.out.println("Error desc: " + e.getMessage());
}
I spent several hours on such case. I saw only touch keys logs. Nothing more. Problem was... smarthphone. After restarting was OK. Disconnecting cable caused problem returned. Had to restart it again.
Looks like the Android USB communication is not well designed.
Using the SDK 4.0.3 you have to explicitly select it on debug configurations > project > target or else it will never show using Eclipse Indigo (3.7). Of course an eclipse restart ensues.
I had a problem seeing simple log output in logcat as well. My problem was solved when I installed the latest JDK. I just setup a new development machine and only had the JRE installed and instaling the JDK worked for me.
None of the other answers worked for me, but this did:
I removed my project from my workspace, then deleted anything that started with a dot (.settings, .project, etc.) from the project folder. Then I re-imported the projected. I'm missing some settings and breakpoints but at least it works.
I had been experiencing this problem and nothing seemed to work until I moved the log call into a handler. Now it works every time, no matter where you are at.
I made the mistake of typing in a search term in the logcat search box.
I forgot to delete it and hence couldn't see the new logs. Since they didn't match my search term and weren't displayed.
In my case, I had to remove this line:
<application
android:debuggable="false" <!-- Remove this line -->
..../>
From Application tag in my Manifest file.
Best solution for me was restart adb server (while I have Enabled ADB integration in Android studio - Tools - Android - checked). To do this quickly I created adbr.bat file inside android-sdk\platform-tools directory (where is adb.exe located) with this inside:
adb kill-server
adb start-server
Because I have this folder in PATH system variable, always when I need restart adb from Android studio, I can write only into terminal adbr and it is done.
Another option to do this is through Android Device Monitor in Devices tab - Menu after click on small arrow right - Reset adb.
For eclipse:
1) Go to ddms perspective.
2) Make sure that correct device is selected.
3) If already selected and not displaying logs, then restart ABD.
* Hope this will solve.
I restarted the ADB service as well with "adb usb" and fixes the problem for me. In fact, only one of my activities didn't log anymore. All the others did log stuff. After restart adb everything works like a charm again. For the other people who're searching for another solution: adb kill-server, adb start-server in CLI will often fix your problem aswell.
make your app force close once
this will start LogCat again ...
use this for force close :D
setContentView(BIND_AUTO_CREATE);
some times the problem is not from pc on the other hand IDE,ADB etc, but it arises from your device that doesn't send logs to ADB so if you tried all the ways mentioned before and still your logcat is empty try to restart your device and try again.I tried all the ways mentioned above and neither of them worked but after a restart on my phone logcat worked like magic
I have this problems and fixed, String TAG without space:
"my tag" // noting show
"my_tag" // is ok
In my case I just had to add a name to the String. In first instance I just had a space in between the brackets
private static final String TAG = " ";
but after adding a name it worked perfectly.
private static final String TAG = "oncreate";
After upgrade to Android 3.6.1, I have experienced this issue multiple times.
The only thing that works in my case is RESTARTING THE DEVICE.

Android Emulator Debugging, Code will not Update

I'm having a troubling problem testing some code for and Android app. My app has two parts, and activity where the user changes some settings, and a broadcast receiver that responds to SMS messages, both in the same package.
Here's the problem, I first implemented some simple code to test out the broadcast receiver and the activity, and both worked fine. But then as I tried to refine the code, I noticed the emulator wasn't picking up any of my changes. Event went so far as to uninstall the app from the emulator and try again, no luck. Then I added some extra Toast popups to my receiver, nothing, still running the old code. I know its running the old code because its sending out an SMS using a string constant that is no longer in the current code, so it should be impossible that it respond with that value.
Here's the kicker that has me confused. For fun I made a change to my activity. Ran the project from Eclipse and that change showed up! Tried to test the receiver code again, runs the old code that doesn't even exist anymore!!
How in the world can half the package update, and the other half not?
Can anyone help me out 'cause I'm about ready to lose my mind.
I had a similar problem. Changes made to classes imported from another project didn't get picked up by eclipse, but those made to classes in the current android project were.
Making a change to the current android project (inserting a blank line and deleting it) seemed to make eclipse pick up all the changes made and upload the app to the emulator.
I had this problem too, Now I found a working solution. Just follow these steps:
Run your project normally.
When emulator started, run your project again (DO NOT close the first emulator)
Then the updated application will be uploaded into emulator
I can't really be sure what happened but creating an new emulator image appeared to solve the issue.
I don't know why it happens but it's a problem I have all the time.
What I typically do is
Close the emulator
Close Eclipse
Reopen Eclipse
Clean the projects (in Eclipse, select Project -> Clean... -> Clean all projects)
Rerun the emulator
Annoying as hell but seems to work for me.
I'm having this problem too. It mostly happens when errors are entered into the code. The strange thing is if I go back to the original code, Eclipse doesn't revert to the original code. One thing that seems to help is to temporary delete the contents of a file, save, and rebuild, and then enter the contents back into the file, save, and rebuild.
How is one supposed to debug in such an environment?

Categories

Resources