I recently updated my project to the Android Support Library 23.1 and this part of my code now gives an error.
It was working before the update and commenting just this part out allows me to run the app fine.What exactly is wrong or has change?
Glide.with(getApplicationContext())
.load(R.drawable.banner)
.fitCenter()
.override(width, height / 2)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.into(back);
if (picture != null) {
Glide.with(getApplicationContext())
.load(picture)
.fitCenter()
.override(width / 2, height / 2)
.into(profile);
} else {
Glide.with(getApplicationContext())
.load(R.drawable.profile_p)
.fitCenter()
.override(width / 2, height / 2)
.into(profile);
}
This is the error log.
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: FATAL EXCEPTION: main
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: Process: atsystems.cal, PID: 16313
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{atsystems.cal/atsystems.cal.MainActivity}: java.lang.IllegalArgumentException: You must pass in a non null View
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5254)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: Caused by: java.lang.IllegalArgumentException: You must pass in a non null View
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:678)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at com.bumptech.glide.DrawableRequestBuilder.into(DrawableRequestBuilder.java:448)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at atsystems.cal.MainActivity.onCreate(MainActivity.java:74)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5990)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5254)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I am using a navigation drawer layout which contains a navigation view.This navigation view contains the header layout which i display and as it turns out the code which i commented out is used to display pictures for the header layout.So has anything changed in the new library update?
It would seem that there is an issue regarding the navigation view. NavigationView findViewById can't find header view
The current fix/workaround is to find the header layout using.
final NavigationView mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
final View headerLayout = mNavigationView.inflateHeaderView(R.layout.header);
Once that is done you can refer to each element in the header layout like so.
final ImageView profile = (ImageView) headerLayout.findViewById(R.id.profile_image);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With