2

I am trying to debug some data, and I have a byte[] that I know has text in it. But I can't figure out how to view it as text, or even get a hex representation that I could convert to text. I have tried creating a custom type converter that uses 'new String(this)', but then it just shows 'instance of java.lang.String'

Note: I am using Android Studio, which is build on IntelliJ

Thayne
  • 6,619
  • 2
  • 42
  • 67
  • 3
    Is creating a new watch `new String(nameOfYourBytesArrayVariable)` not an option? – Roman Vottner Jul 17 '15 at 00:33
  • I tried that, it complained that it couldn't resolve String, and if I used java.lang.String it complained that it couldn't resolve java.lang.String. I am using android studio if that makes a difference. – Thayne Jul 17 '15 at 16:39
  • As you asked for presenting a hex-representation, maybe [this post](http://stackoverflow.com/questions/17447013/android-studio-debugging-display-variables-as-hexadecimal) is helpful to you as well – Roman Vottner Jul 17 '15 at 16:49
  • According to [this post](http://stackoverflow.com/questions/25057447/how-to-put-a-watchsee-how-a-variable-is-modified-in-android-studio) Android Studio should support wach variables too, however, the execution needs to be within the visibility-context of the respective variable. If it is defined in a method locally, while debugging you need to be inside that method to actually be able to use a watch. [This page](https://developer.android.com/tools/debugging/debugging-studio.html) has also good amount of infos on how to debug in general with Android Studio – Roman Vottner Jul 17 '15 at 16:51
  • @RomanVottner I want to see the byte[] as a string. I can look at the hex value for each byte individually, but I can't figure out how to get a string with ALL the hex values that I could easily convert to a string, without having to manually type in each byte. – Thayne Jul 17 '15 at 16:55
  • @RomanVottner I can set a break point and view the data as a byte[] I just can't figure out how to view it as a UTF-8 encoded string from that byte[]. – Thayne Jul 17 '15 at 16:56

1 Answers1

5
  1. Customize String Data View

String Data View

  1. View as string

View as string

jk2K
  • 4,279
  • 3
  • 37
  • 40
  • I should be like that but your solution are crashing and skipping debugging but for `ByteString` i got String after adding `utf8()` in both renderer. thanks – Qamar Jul 20 '16 at 17:01