Hope I am not duplicating a question here, but all of the ones I found on stack exchange dont seem to fit my need.
Here is a snippet of my code:
public class custom_row_adapter extends ArrayAdapter<Integer> {
custom_row_adapter(Context context, ArrayList<Integer> picId, String url, String fullUrl) {
super(context, R.layout.activity_custom_row_adapter, picId);
}
//Do stuff
Everything works fine in the app, now I try to generate a signed apk and I get a nice little error that I need a default constructor. So I decide that I will add one, now my code looks like this:
public class custom_row_adapter extends ArrayAdapter<Integer> {
public custom_row_adapter() {
super();
}
custom_row_adapter(Context context, ArrayList<Integer> picId, String url, String fullUrl) {
super(context, R.layout.activity_custom_row_adapter, picId);
}
//Do Stuff
Now I get a new error that it can't find a suitable constructor for ArrayAdapter()
So I get on google and find a couple posts and one tells me I can bypass that error by searching Instantiable in the Inspections tab and turning it to WARNING that it will fix it. Didn't work.
So how do I fix this? Thanks in advance.
EDIT: for those of you saying I can just add public custom_row_adpater(){}
EDIT 2: Here are some more pictures, pay attention to the Error on bottom left:
This error means that for some reason the lint (wrongly) thinks that your adapter should be instantiatable. This apply to objects which may be instantiated by the system like activities, broadcast receivers, but not to adapters because they are always instantiated in the application's code. For example commonly used adapters like ArrayAdapter
or SimpleCursorAdapter
don't have a default constructor.
You can try to make Android Studio come to his senses, for example update the build tools, clean the workspace, delete the build
directory... If it doesn't work you can add the requested (and useless) default contructor :
public custom_row_adapter() {
super(null , 0);
throw new RuntimeException("This is a workaround and should not be used");
}