Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNiyamat Almass
8,176 PointsDebugger not working?
Hi everyone when I run my app in Genymotion emulator I get the jsonData.But when I set a breakpoin in my code and debug the app the debugger show me
Connected to the target VM, address : 'local host:8631', transport: 'socket'
And then I wait for a long time but nothing show in my debugger.The console image is https://drive.google.com/open?id=0Bze-_k4O9A53S0o4UlM2dkhsakE
https://drive.google.com/open?id=0Bze-_k4O9A53SEtyaUliSFFJbjA where I set my breakpoint
My code is
package com.example.niyamat.testing;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import java.io.IOException;
public class MainActivity extends ActionBarActivity {
public static final String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
double latitude = 37.8267;
double longitude = -122.423;
String apiKey = "b4de63a98386f7e128deaa126a3e23dd";
String forecastUrl = "https://api.forecast.io/forecast/" + apiKey + "/" + latitude + "," + longitude;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(forecastUrl)
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
}
@Override
public void onResponse(Response response) throws IOException {
String jsonData = response.body().string();
try {
Log.v(TAG, jsonData);
} catch (Exception e) {
Log.v(TAG, "Exception caught", e);
}
}
});
}
}
My emulator is not in airplane mode and wi-fi is on.
""Note: I get the jsonData in logcat when I run my app.""
1 Answer
Steve Hunter
57,712 PointsOK - you just gave me access to those G-drive screen shots.
So, you've put a breakpoint before the code writes the JSON data to the Log. If you click on Step over, it'll execute that line and write the JSON to the Log. If you hover over the variable jsonData
your should see that it contains data - or you can add it to a watch list where you can explore what it contains.
I'm not sure what your question is. With the breakpoint at that position, the Log won't show anything - you need to execute that line first.
Steve.
Niyamat Almass
8,176 PointsNiyamat Almass
8,176 PointsOops!Sorry! for the photo.
I am not good at English so I cannot described my question properly sorry for that .But I found a similar question in http://stackoverflow.com/questions/21745143/android-studio-cant-connect-to-debug-devices
I have the same problem but my operating system is windows 7 and my android studio version is 1.3.2 so the answer of the stackoverflow is not working for me.
Please help me I am really tired with this problem.