Android Studio Debugger Highlights the Wrong Lines

Android Studio debugger highlights the wrong lines

This is a problem with dx, which is the part of the build that turns your Java .class files into .dx files for packaging into Android. According to this:

https://code.google.com/p/android/issues/detail?id=34193

if a function has multiple return paths, dx merges the return instruction into a single return instruction, so during debugging, the debugger can't tell which line a return belongs to and things jump around. This corresponds to what I see when I try to reproduce your problem: each time through the loop it does the if (a == 3) check, jumps to the return 0 at the end, and then jumps back into the loop. You're seeing that last return 0 get merged with the return retval in the middle of the loop.

I doubt this will be fixed any time soon, so you may just have to learn to live with it. Sorry, I know it's kinda crazy.

Can't reach some lines debugging android app

try to disable code shrinking in your build.gradle file. it's located in your projects root directory.
Under buildTypes, make sure minifyEnabled is set to false. should look something like this:

buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
}

Java code executing incorrectly when debugging with Android Studio

I've figured out the problem, thanks to Mike M. pointing out to a similar issue at Android Studio debugger highlights the wrong lines.

Apparently, correct code was executing, but because a completely irrelevant bug was present in my code somewhere else, it was masking the issue, and because debugger was behaving incorrectly, I've simply thought there was something going on related to this issue. I've fixed the other bug, and changed my code in onCreateViewHolder to this:

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder holder = null;
if(viewType == POST_VIEW_TYPE){
View view = LayoutInflater.from(App.instance).inflate(R.layout.item_post, parent, false);
holder = new PostViewHolder(view);
}else{
View view = LayoutInflater.from(App.instance).inflate(R.layout.item_user, parent, false);
holder = new UserViewHolder(view);
}
return holder;
}

It now works (and debugs) correctly. It's interesting to see Google's own IDE for Android can't step through (and doesn't even display a warning telling that debugging may step incorrectly due to multiple return paths) the code that Dalvik produces. I wish ART has solved this issue.

Return not working, getItemViewType behaviour is extremely weird - I cannot explain it

It's already answered look at
[Simple function going past return statement and Android Studio debugger highlights the wrong lines.

In short try to rebuild your project, if that doesn't help you restart android studio.

Intellij: Code highlighted purple in debug mode

This is called "Smart Step Into", and allows you to select the method, that you would like to step into for debugging, if there are multiple method calls in a line (like in your example). To use this feature, you would press Shift + F7, and then either click on the method, or use the arrow keys or tab button to choose the method, and then either press Enter or F7 to enter that method.

For reference: https://www.jetbrains.com/help/idea/stepping-through-the-program.html#smart-step-into

Android Studio stacktrace is unclickable

You can do this using the 'Analyze Stacktrace` function. This can be found on the menu:

Analyze -> Analyze Stacktrace

Sample Image

Just paste your stacktrace from DDMS into the dialog, click OK and it will give you one with clickable links (if it can find them).



Related Topics



Leave a reply



Submit