android error和解决方法合集

错误1:Binary XML file line #24: Error inflating class android.support.design.widget.NavigationView

inflate Caused by: java.lang.reflect.InvocationTargetException
在使用NavigationView过程中一直崩溃,系统报错如上。在网上找了很多答案没有生效,终于在stackOverflow里找到了答案,原因是com.android.support:appcompat和com.android.support:design版本不一样导致的,版本号改成一样的就好了。

原文链接:http://stackoverflow.com/questions/30709419/error-inflating-class-android-support-design-widget-navigationview

错误2:UnsupportedOperationException  client.interceptors().add(interceptor)

解决方法:

OkHttpClient okClient = new OkHttpClient(); okClient.interceptors().add(new Interceptor() {...});

改成下面的写法

OkHttpClient okClient = new OkHttpClient.Builder() .addInterceptor( new Interceptor() {...}) .build();

参考:http://stackoverflow.com/questions/34674820/unsupported-operation-android-retrofit-okhttp-adding-interceptor-in-okhttpcl