-
编译报错:
The android.dexOptions.incremental property is deprecated and it has no effect on the build process.
android.dexOptions.incremental属性已被弃用,它对构建过程没有影响。
解决办法:
app的build.gradle修改dexOptions {
// incremental true //这一行注掉或者删掉
javaMaxHeapSize “4g”
}
2.场景:创建类继承IntentService,子类没有无参的构造方法。运行时报错java.lang.InstantiationException
解决办法:
IntentService 是继承自 Service 并处理异步请求的一个类。Service是四大组件之一,我们无法进行手动实例化,实例化是系统来进行的。而且系统是用参数为空的构造函数来实例化Service的,在无参构造方法中调用super(“name”)来进行创建。所以继承IntentService必须创建一个无参的构造方法。
public MyIntentService() {
super("MyIntentService");
}
3.场景:创建recycleview的adapter时,初始化adapter布局的时候报错:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child’s parent first.
解决办法:
将@Override public PictureHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_picture, parent); return new PictureHolder(view); }
改为
@Override
public PictureHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_picture, null);
return new PictureHolder(view);
}`
parent置为为null