1.Attempt to invoke virtual method ‘int android.view.View.getImportantForAccessibility()’
原因:在adapter中getView返回的时候返回null就报这个异常。
2.在使用retrofit的时候出现这个错误:java.lang.ExceptionInInitializerError
原因:Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL).build();这段代码中BASE_URL有问题,没有以“/”结束。
3.AlertDialog调用调用getButton()方法返回为null
原因:①.AlertDialog.Builder对象没有调用setPositiveButton()或者setNegativeButton(),所以AlertDialog对象再调用getButton()获取对应Button时为null.
②.AlertDialog对象没有调用show()方法也会返回null。
4.异常:java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
原因:在RelativeLayout内,如果两个控件循环引用就可能出现这个问题,比如:设置A在B下方,又设置了B在A上方,不知道怎么绘制了才会发生这种错误。
5.异常:android.view.WindowManager$BadTokenException
解决:https://blog.csdn.net/crash163/article/details/51829341
6.导入项目提示:Failed to resolve: support-core-utils Open File Failed to resolve: support-compat Open File
如下图:
只需要把
里面的
再重新同步一下即可
7.Android Studio升级导致No such property: FOR_RUNTIME for class: org.gradle.api.attributes.Usage
解决:classpath 'com.novoda:bintray-release:0.5.0' 升级最新版本,比如:classpath 'com.novoda:bintray-release:0.8.1'
8.The layout <layout> in layout has no declaration in the base layout folder [error]
解决:File => Invalidate Caches / Restart => Invalidate and Restart.
stackoverflow原文地址:https://stackoverflow.com/questions/52547657/the-layout-layout-in-layout-has-no-declaration-in-the-base-layout-folder-erro
9.intent传递数据太大,报Caused by: android.os.TransactionTooLargeException:data parcel size xxxx bytes异常解决方案
解决:解决方法有二:
第一:将传递的信息封装在一个静态的类中,或则封装在跳转对象的一个静态属性中,效率高,但是耦合性也高!(这种方法在stackoverflow网站看到的,有兴趣可以点击查看详情)
Intent intent = new Intent(this,SecondActivity.class);
DataSave.setValue(value);//将value设置到静态类DataSave中
//SecondActivity.value = value;//或则将value设置到SecondActivity的静态属性中
startActivity(intent);
第二:将传递的信息做本地存储,如SP存储、数据库等,然后在跳转对象中取出来,不会提高程序的耦合性,但是效率较低。
原博客地址:https://blog.csdn.net/chaoyangsun/article/details/76254267