2

I am having another newbie problem. As you can see in my error message. At my MainActivity.java, line 125 is presenting a Null Pointer Exception:

    05-03 22:19:17.559 22615-22615/com.example.andrewjakevillegas.stormy E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.andrewjakevillegas.stormy, PID: 22615
java.lang.
NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
at com.example.andrewjakevillegas.stormy.MainActivity.updateDisplay(MainActivity.java:125)
at com.example.andrewjakevillegas.stormy.MainActivity.access$200(MainActivity.java:38)
at com.example.andrewjakevillegas.stormy.MainActivity$1$1.run(MainActivity.java:100)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Here is my MainActivity.java

package com.example.andrewjakevillegas.stormy;

import...    

public class MainActivity extends ActionBarActivity {

    public static final String TAG = MainActivity.class.getSimpleName();

    private CurrentWeather mCurrentWeather;

    @BindView(R.id.timeLabel)
    TextView mTimeLabel;
    @BindView(R.id.temperatureLabel)
    TextView mTemperatureLabel;
    @BindView(R.id.humidityLabel)
    TextView mHumidityValue;
    @BindView(R.id.precipLabel)
    TextView mPrecipValue;
    @BindView(R.id.summaryLabel)
    TextView mSummaryLabel;
    @BindView(R.id.iconImageView)
    ImageView mIconImageView;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient mClient;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main );
        ButterKnife.bind( this );



        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();
                        Log.v( TAG, jsonData );
                        if (response.isSuccessful()) {
                            mCurrentWeather = getCurrentDetails( jsonData );
                            runOnUiThread( new Runnable() {
                                @Override
                                public void run() {
                                    updateDisplay();
                                }
                            } );
                        } else {
                            alertUserAboutError();
                        }
                    } catch (IOException e) {
                        Log.e( TAG, "Exception caught: ", e );
                    } catch (JSONException e) {
                        Log.e( TAG, "Exception caught: ", e );
                    }
                }
            } );
        } else {
            Toast.makeText( this, getString( R.string.network_unavailable_message ),
                    Toast.LENGTH_LONG ).show();
        }
        Log.d( TAG, "Main UI code is running!" );

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        mClient = new GoogleApiClient.Builder( this ).addApi( AppIndex.API ).build();
    }

    private void updateDisplay() {
        mTemperatureLabel.setText( mCurrentWeather.getTemperature() + "" );
    }

    private CurrentWeather getCurrentDetails(String jsonData) throws JSONException {
        JSONObject forecast = new JSONObject( jsonData );
        String timezone = forecast.getString( "timezone" );
        Log.i( TAG, "From JSON: " + timezone );

        JSONObject currently = forecast.getJSONObject( "currently" );
        CurrentWeather currentWeather = new CurrentWeather();
        currentWeather.setHumidity( currently.getDouble( "humidity" ) );
        currentWeather.setTime( currently.getLong( "time" ) );
        currentWeather.setIcon( currently.getString( "icon" ) );
        currentWeather.setPrecipChance( currently.getDouble( "precipProbability" ) );
        currentWeather.setSummary( currently.getString( "summary" ) );
        currentWeather.setTemperature( currently.getDouble( "temperature" ) );

        return new CurrentWeather();
    }

    private boolean isNetworkAvailable() {
        ConnectivityManager manager = (ConnectivityManager)
                getSystemService( Context.CONNECTIVITY_SERVICE );
        NetworkInfo networkInfo = manager.getActiveNetworkInfo();
        boolean isAvailable = false;
        if (networkInfo != null && networkInfo.isConnected()) {
            isAvailable = true;
        }

        return isAvailable;
    }

    private void alertUserAboutError() {
        AlertDialogFragment dialog = new AlertDialogFragment();
        dialog.show( getFragmentManager(), "error_dialog" );
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        mClient.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse( "http://host/path" ),
                // TODO: Make sure this auto-generated app URL is correct.
                Uri.parse( "android-app://com.example.andrewjakevillegas.stormy/http/host/path" )
        );
        AppIndex.AppIndexApi.start( mClient, viewAction );
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse( "http://host/path" ),
                // TODO: Make sure this auto-generated app URL is correct.
                Uri.parse( "android-app://com.example.andrewjakevillegas.stormy/http/host/path" )
        );
        AppIndex.AppIndexApi.end( mClient, viewAction );
        mClient.disconnect();
    }
}

This particular line of code is giving me the headache.This is line 125 from my error log.

private void updateDisplay() {
        mTemperatureLabel.setText( mCurrentWeather.getTemperature() + "" );
    }

I have checked my layout. I got the right id and type of TextView.

Here is my activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:paddingBottom="@dimen/activity_vertical_margin"
            tools:context=".MainActivity"
            android:id="@+id/relativeLayout"
            android:background="#fffc970b">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/temperatureLabel"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:textColor="@android:color/white"
    android:textSize="150dp"
    android:text="100"/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/degreeImageView"
    android:layout_alignTop="@+id/temperatureLabel"
    android:layout_toRightOf="@+id/temperatureLabel"
    android:layout_toEndOf="@+id/temperatureLabel"
    android:layout_marginTop="50dp"
    android:src="@drawable/degree"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="At 5:00 PM it will be"
    android:id="@+id/timeLabel"
    android:layout_above="@+id/temperatureLabel"
    android:layout_centerHorizontal="true"
    android:textColor="#95ffffff"
    android:textSize="18sp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Alcatraz Island, CA"
    android:id="@+id/locationLabel"
    android:layout_above="@+id/timeLabel"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="60dp"
    android:textColor="@android:color/white"
    android:textSize="24sp"/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/iconImageView"
    android:layout_alignBottom="@+id/locationLabel"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:src="@drawable/cloudy_night"/>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/temperatureLabel"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="10dp"
    android:weightSum="100"
    android:id="@+id/linearLayout">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="50">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="HUMIDITY"
            android:id="@+id/humidityLabel"
            android:textColor="#95ffffff"
            android:gravity="center_horizontal"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="0.88"
            android:id="@+id/humidityValue"
            android:textColor="@android:color/white"
            android:textSize="24sp"
            android:gravity="center_horizontal"/>
    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="50">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="RAIN/SNOW?"
            android:id="@+id/precipLabel"
            android:textColor="#95ffffff"
            android:gravity="center_horizontal"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="100"
            android:id="@+id/precipValue"
            android:textColor="@android:color/white"
            android:textSize="24sp"
            android:gravity="center_horizontal"/>
    </LinearLayout>
</LinearLayout>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Stormy with a chance of meatballs"
    android:id="@+id/summaryLabel"
    android:layout_below="@+id/linearLayout"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="40dp"
    android:textColor="@android:color/white"
    android:textSize="18dp"
    android:gravity="center_horizontal"/>

My Current Weather Java Class should get and set the right values.

public int getTemperature() {
    return (int)Math.round(mTemperature);
}

public void setTemperature(double temperature) {
    mTemperature = temperature;
}

Here is a copy of my CurrentWeather.java just in case you need to refer to it.

    package com.example.andrewjakevillegas.stormy;

public class CurrentWeather {
    private String mIcon;
    private long mTime;
    private double mTemperature;
    private double mHumidity;
    private double mPrecipChance;
    private String mSummary;

    public String getIcon() {
        return mIcon;
    }

    public void setIcon(String icon) {
        mIcon = icon;
    }

    public int getIconId(){
        int iconId = R.drawable.clear_day;

        if (mIcon.equals("clear-day")){
            iconId = R.drawable.clear_day;
        }

        else if (mIcon.equals("clear-night")){
            iconId = R.drawable.clear_night;
        }

        else if (mIcon.equals("rain")) {
            iconId = R.drawable.rain;
        }
        else if (mIcon.equals("snow")) {
            iconId = R.drawable.snow;
        }
        else if (mIcon.equals("sleet")) {
            iconId = R.drawable.sleet;
        }
        else if (mIcon.equals("wind")) {
            iconId = R.drawable.wind;
        }
        else if (mIcon.equals("fog")) {
            iconId = R.drawable.fog;
        }
        else if (mIcon.equals("cloudy")) {
            iconId = R.drawable.cloudy;
        }
        else if (mIcon.equals("partly-cloudy-day")) {
            iconId = R.drawable.partly_cloudy;
        }
        else if (mIcon.equals("partly-cloudy-night")) {
            iconId = R.drawable.cloudy_night;
        }


        return iconId;
    }

    public long getTime() {
        return mTime;
    }

    public void setTime(long time) {
        mTime = time;
    }

    public int getTemperature() {
        return (int)Math.round(mTemperature);
    }

    public void setTemperature(double temperature) {
        mTemperature = temperature;
    }

    public double getHumidity() {
        return mHumidity;
    }

    public void setHumidity(double humidity) {
        mHumidity = humidity;
    }

    public double getPrecipChance() {
        double precipPercentage = mPrecipChance * 100;
        return (int)Math.round(precipPercentage);
    }

    public void setPrecipChance(double precipChance) {
        mPrecipChance = precipChance;
    }

    public String getSummary() {
        return mSummary;
    }

    public void setSummary(String summary) {
        mSummary = summary;
    }


}

Here are the image results when I ran the debugger.

enter image description here

The butterknife is not working from what it looks like. Do you have any suggestions how I can solve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Where did you initialize " mTemperatureLabel " textView..? – Saritha G May 03 '16 at 12:55
  • you have not initialized any of your textViews...... – Opiatefuchs May 03 '16 at 12:56
  • 1
    Can you check what is null using the debugger? Set a breakpoint at line 125, and look if the `TextView` or the `mCurrentWeather` are null. – yennsarah May 03 '16 at 13:03
  • 2
    Possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – F43nd1r May 03 '16 at 13:04
  • @Amy The stacktrace shows it is `mTemperatureLabel` that is null – Enrico May 03 '16 at 13:06
  • 1
    Also, I think you shouldn't post your API key online... :) – yennsarah May 03 '16 at 13:06
  • where is line 125 in your code? – has19 May 03 '16 at 13:06
  • I know. But I can't see the problem with his code. – yennsarah May 03 '16 at 13:06
  • Why do you use `runOnUiThread`? After a longer staring at your code, I don't see why it should be necessary, since I don't see you leaving the UI thread..? – yennsarah May 03 '16 at 13:13
  • It looks like you're using butterknife - as a first step I'd try to call findViewById and see what if it works. If it works it means something with butterknife isn't working. – nitzanj May 03 '16 at 13:16
  • Does it matter if you have the TextView and BindView annotation on two separate lines? All examples I see have it on a single line. – stefana May 03 '16 at 13:46
  • @Amy where is my API key located? It is a free API from forecast.io. Sorry, newbie mistakes. – Andrew Jake Villegas May 04 '16 at 09:12
  • Amy, I took your advise and ran the debugger. Unfortunately, @nitzanj is right. Something within my butterknife is not working. I do not know what is going on. Let me post the results of the debugger. – Andrew Jake Villegas May 04 '16 at 09:19
  • Amy, I use the runOnUiThread to call the data and place on the main UI from the enqueue method. – Andrew Jake Villegas May 04 '16 at 09:34
  • I removed the API key. Even it is free.. You never know. But do you need to call `runOnUiThread`? Maybe I miss something, but it doesn't look like your api call/response is in another thread. – yennsarah May 04 '16 at 12:11
  • I think I have removed my Api key Amy. My call.enqueue is in the MainActivity.java. I will manually call the variables instead of using butterknife. Let me see if that works. Thank you for your help Amy and the guys. – Andrew Jake Villegas May 05 '16 at 04:48

4 Answers4

3

I Found the answer to my problem.

You have to download - copy and paste the whole butterknife-compiler (code below)to your build gradle. I was just copying the dependencies and adding it to my gradle dependencies. Which is giving me the problem.

buildscript {
  repositories {
    mavenCentral()
   }
  dependencies {
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  }
}

apply plugin: 'com.neenbedankt.android-apt'

dependencies {
  compile 'com.jakewharton:butterknife:8.0.1'
  apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
0

Why are you using updateDisplay in a seperate runnable? And then you run this new runnable on the main thread. Seems weird.

anyway, the problem is that your mTemperatureLabel is not initialized. Maybe your bindView operation is not finished when you call the first updateDisplay method.

Edit: As I mentioned in comments, I would not use Butterknife because there are no benefits and you will get problems while debug errors. Anyway, if you wanna use Butterknife no matter what, try Bind instead of BindView.

Ben
  • 696
  • 9
  • 19
  • You are right. I am running problems with my butterknife process. I am trying to figure out what is going on. I have updated my post to reveal the results of my debugging. – Andrew Jake Villegas May 04 '16 at 09:25
  • "The butterknife is not working from what it looks like. Do you have any suggestions how I can solve this? Thank you." Yes, don't use butterknife. It makes no sense, you have no benefits by using this library. Even worse, you will get problems to debug errors and bugs. There are reasons why google is using their way to initialize java objects from xml layout without dependency injection. – Ben May 04 '16 at 12:16
  • Thank you @ChampS. I will call all my variables manually. It seems for similar reasons the newest butterknife version is giving other people the problem. https://github.com/JakeWharton/butterknife/issues – Andrew Jake Villegas May 05 '16 at 04:43
0
package com.example.com;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;


import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
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 org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;

import butterknife.Bind;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {

public static final String TAG = MainActivity.class.getSimpleName();

private CurrentWeather mCurrentWeather;

@Bind(R.id.timeLabel)
TextView mTimeLabel;
@Bind(R.id.temperatureLabel)
TextView mTemperatureLabel;
@Bind(R.id.humidityLabel)
TextView mHumidityValue;
@Bind(R.id.precipLabel)
TextView mPrecipValue;
@Bind(R.id.summaryLabel)
TextView mSummaryLabel;
[![enter image description here][1]][1]@Bind(R.id.iconImageView)
ImageView mIconImageView;
/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See https://g.co/AppIndexing/AndroidStudio for more information.
 */
private GoogleApiClient mClient;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.activity_main );
    ButterKnife.bind( this );


    String apiKey = "ur_key";
    double latitude = 37.8267;
    double longitude = -122.423;
    String forecastURL = "https://api.forecast.io/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(Request request, IOException e) {

            }

            @Override
            public void onResponse(Response response) throws IOException {

                try {
                    String jsonData = response.body().string();
                    Log.v( TAG, jsonData );
                    if (response.isSuccessful()) {
                        mCurrentWeather = getCurrentDetails( jsonData );
                        runOnUiThread( new Runnable() {
                            @Override
                            public void run() {
                                updateDisplay();
                            }
                        } );
                    } else {
                        alertUserAboutError();
                    }
                } catch (IOException e) {
                    Log.e( TAG, "Exception caught: ", e );
                } catch (JSONException e) {
                    Log.e( TAG, "Exception caught: ", e );
                }
            }
        } );
    } else {
        Toast.makeText( this,  "not available",Toast.LENGTH_SHORT )
               .show();
    }
    Log.d( TAG, "Main UI code is running!" );

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    mClient = new GoogleApiClient.Builder( this ).addApi( AppIndex.API ).build();
            }


private void updateDisplay() {
    mTemperatureLabel.setText( mCurrentWeather.getTemperature() + "" );
}

private CurrentWeather getCurrentDetails(String jsonData) throws JSONException {
    JSONObject forecast = new JSONObject( jsonData );
    String timezone = forecast.getString( "timezone" );
    Log.i( TAG, "From JSON: " + timezone );

    JSONObject currently = forecast.getJSONObject( "currently" );
    CurrentWeather currentWeather = new CurrentWeather();
    currentWeather.setHumidity( currently.getDouble( "humidity" ) );
    currentWeather.setTime( currently.getLong( "time" ) );
    currentWeather.setIcon( currently.getString( "icon" ) );
    currentWeather.setPrecipChance( currently.getDouble( "precipProbability" ) );
    currentWeather.setSummary( currently.getString( "summary" ) );
    currentWeather.setTemperature( currently.getDouble( "temperature" ) );

    return new CurrentWeather();
}

private boolean isNetworkAvailable() {
    ConnectivityManager manager = (ConnectivityManager)
            getSystemService( Context.CONNECTIVITY_SERVICE );
    NetworkInfo networkInfo = manager.getActiveNetworkInfo();
    boolean isAvailable = false;
    if (networkInfo != null && networkInfo.isConnected()) {
        isAvailable = true;
    }

    return isAvailable;
}

private void alertUserAboutError() {
    AlertDialogFragment dialog = new AlertDialogFragment();
    dialog.show( getFragmentManager(), "error_dialog" );
}

@Override
public void onStart() {
    super.onStart();

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    mClient.connect();
    Action viewAction = Action.newAction(
            Action.TYPE_VIEW, // TODO: choose an action type.
            "Main Page", // TODO: Define a title for the content shown.
            // TODO: If you have web page content that matches this app activity's content,
            // make sure this auto-generated web page URL is correct.
            // Otherwise, set the URL to null.
            Uri.parse( "http://host/path" ),
            // TODO: Make sure this auto-generated app URL is correct.
            Uri.parse( "android-app://com.example.com/http/host/path" )
    );
    AppIndex.AppIndexApi.start( mClient, viewAction );
}

@Override
public void onStop() {
    super.onStop();

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    Action viewAction = Action.newAction(
            Action.TYPE_VIEW, // TODO: choose an action type.
            "Main Page", // TODO: Define a title for the content shown.
            // TODO: If you have web page content that matches this app activity's content,
            // make sure this auto-generated web page URL is correct.
            // Otherwise, set the URL to null.
            Uri.parse( "http://host/path" ),
            // TODO: Make sure this auto-generated app URL is correct.
            Uri.parse( "android-app://com.example.andrewjakevillegas.stormy/http/host/path" )
    );
    AppIndex.AppIndexApi.end( mClient, viewAction );
    mClient.disconnect();
}

enter image description here

fasal shah
  • 156
  • 1
  • 1
  • 8
  • Fasal that is layout showing. I need the json object from the api to populate the display. My butterknife section is giving the problem. I have updated my post to show the results of my debugging. – Andrew Jake Villegas May 04 '16 at 09:37
  • what i solved is your question "null point exception" check how i have Bind in code.. your code is not displaying means there is some logical error.. Anyway i debugged it in (private CurrentWeather getCurrentDetails) and i got was correct values in log.. debug your code in (public void updateDisplay) and check why values are not reaching there.. as far as i can say for values not displaying on text field is may be you are using old style of retrofit callback and that is the reason ( updateDisplay() ) is happening in runOnUiThread .. – fasal shah May 04 '16 at 17:13
  • Yes. The values gets to the log. But it does not bind with my layout. I will call the variables manually. Butterknife is not working. I will work on this later. Thank you for your help Fasal. – Andrew Jake Villegas May 05 '16 at 04:41
0

In my case i have differents dependencies

First you have similar configuration in yours files build.grade

Problem diferents version [8.0.1 != 8.2.1]

build.gradle(app)

dependencies {
         compile 'com.jakewharton:butterknife:8.2.1'
         apt 'com.jakewharton:butterknife-compiler:8.0.1'
}

i solved using similars versions

dependencies {
         compile 'com.jakewharton:butterknife:8.2.1'
         apt 'com.jakewharton:butterknife-compiler:8.2.1'
}

build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

    }
}

Good Luck!

David Hackro
  • 3,652
  • 6
  • 41
  • 61