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

Data binding is too much headache! please help!

I got many errors after trying to implement data binding. First my gradle wouldn't synch. Eventually after lots of research I found one solution which was to add the below line into the repositories section in the project gradle: google()

Later I started to get the error below: "Can't resolve Android databinding class." And android studio wouldn't give the option to import the right class. Again after a lot of hassle I managed to over come that issue.

However, now I'm getting the below errors, can anyone give me a clue.

error: cannot access ActivityCompatApi23 class file for android.support.v4.app.ActivityCompatApi23 not found error: method does not override or implement a method from a supertype
error: cannot find symbol variable super
error: not an enclosing class: MainActivity error: cannot find symbol method findViewById(int)
error: cannot find symbol method getSystemService(String)
error: cannot find symbol method getFragmentManager()

The below is my code for the onCreate method:

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main);
        final ActivityMainBinding binding = DataBindingUtil.setContentView(MainActivity.this,
                R.layout.activity_main);

        //setting up views to be edited by the data we download
       // iconImageView = findViewById(R.dra)




        // setting up the dark sky link
        darkSkyLabel = (TextView) findViewById(R.id.darkSkyLabel);

        darkSkyLabel.setMovementMethod(LinkMovementMethod.getInstance());


        String temp = "https://api.darksky.net/forecast/339f2e72fcfe43726851f16fa755b463/37.8267,-122.4233";

        String apiKey = "339f2e72fcfe43726851f16fa755b463";

        double latitude = 37.8267;
        double longitude = -122.4233;

        String forecastURL = "https://api.darksky.net/forecast/"
                + apiKey
                + "/"
                + latitude + ","
                + longitude;

        if (isNetworkAvailable()) {


            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(Call call, IOException e) {

                }

                @Override
                public void onResponse(Call call, Response response) throws IOException {
                    try {
                        String jsonData = response.body().string();
                        //Toast.makeText(MainActivity.this, "This is the onResponse method", Toast.LENGTH_SHORT).show();
                        Log.v(TAG, "This is the onResponse method");
                        Log.v(TAG, jsonData);

                        //Response response = call.execute(); for the the synchronous method

                        if (response.isSuccessful()) {
                            //Toast.makeText(MainActivity.this, "onResponse is successful", Toast.LENGTH_LONG).show();
                            Log.i(TAG, "This is before the method getCurrentDetails");
                            currentweather = getCurrentDetails(jsonData);

                            CurrentWeather displayWeather = new CurrentWeather(
                                    currentweather.getLocationLabel(),
                                    currentweather.getIcon(),
                                    currentweather.getTime(),
                                    currentweather.getTemperature(),
                                    currentweather.getHumidity(),
                                    currentweather.getPrecipChance(),
                                    currentweather.getSummary(),
                                    currentweather.getTimeZone());

                            binding.setWeather(displayWeather);


                            Log.i(TAG, "This is after the method getCurrentDetails");
                        } else {
                            Log.v(TAG, "Not successful");
                            alertUserAboutError();
                        }
                    } catch (IOException e) {
                        //e.printStackTrace();
                        Log.v(TAG, "Connection error", e);
                        //Toast.makeText(MainActivity.this, "onResponse is not successful, connection error exception.", Toast.LENGTH_LONG).show();
                    } catch (JSONException e) {
                        Log.v(TAG, "JSON Exception" , e);
                    }
                }
            });

            TextView temperatureTextView = (TextView) findViewById(R.id.temperatureValue);
            temperatureTextView.setText("test");


        }