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 trial

Android

still getting error while running the app.....

Please can u check my code whether i missed something or not? and why it gives me 59 errors!!!!!!!! that s code in the MainActivity.java in the app

package com.example.owner.stormy;

import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log;

import java.io.IOException;

import okhttp3.Call; import okhttp3.Callback; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response;

public class MainActivity extends AppCompatActivity {

public static final String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String apiKey = "8a6a43b8b708f3b7eb367e63d6b6ed01";
    double latitude = 37.8267;
    double longitude = -122.423;
    String forecastApi = "https://api.forecast.io/forecast/" + apiKey +"/"+ latitude+ "," + longitude;

    OkHttpClient okHttpClient = new OkHttpClient();
    Request request = new Request.Builder().url(forecastApi).build();
    Call call = okHttpClient.newCall(request);
    call.enqueue(new Callback() {
        @Override
        public void onFailure(Call call, IOException e) {

        }

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            try {
                if(response.isSuccessful()){
                    Log.v(TAG, response.body().string());
                }
            } catch (IOException e) {
                Log.d(TAG,"Exception caught: ", e);
            }
        }
    });

    Log.d(TAG,"Main UI code is runing !");

}

}

Mohammed Amin
Mohammed Amin
5,445 Points

Could you post your log with the errors you are getting as well?

Mohammed the Log post is not exist, it always telling me that "Too much output to process!" so what should i do?

Mohammed Amin
Mohammed Amin
5,445 Points

Maybe try filtering the log by adding MainActivity in the filter bar. If you've already done that, I'm not sure what could be causing your errors. I've taken the piece of code you've given me and have run it with no problems.

Did you remember to add the INTERNET permission in your manifest? Do you have the OkHTTP dependency included in your gradle file?

If you have done all this, try a clean build. Go to build at the top of Android Studio, and click clean project.

Thank u so much Mohammed for helping... but still doest work that's what i got in Android Monitor

08-01 00:10:41.643 1198-2921/? E/AudioFlinger: read failed: framesRead=-1 08-01 00:10:41.647 2135-2919/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error -4 during AudioRecord native read 08-01 00:10:41.706 1186-1186/? E/lowmemorykiller: Error writing /proc/2119/oom_score_adj; errno=22 08-01 00:10:41.722 2817-2893/com.google.android.googlequicksearchbox E/OpenGLRenderer: GL error: Out of memory!

actually i didnt understand what does it mean these messages??

Mohammed Amin
Mohammed Amin
5,445 Points

Hmm, it seems like the device is affecting the build somehow. Could you try to close all background processes in your device. Restart it, maybe. Then run a new build and see if you're having the same problem. If you have the same problem, try it on another device if you have access. Or try it on an emulator.

In any case, it doesn't seem like the code here is the problem. As long as you have the INTERNET permission, the OkHttp dependency, then the code you have pasted here should run fine.

bro i did the Internet permission and i restart my computer ... still getting error .... so i ll try on the other device maybe it gonna works really i appreciate ur help.. Thanks alot