Processing with Android Studio Error in fragment.setView arguments

I got this error how to resolve this. Please help!

Wrong 2nd argument in the fragment.setView method

1 Like

Hi @isuru
What happens if you just use:

fragment.setView(frame, this);

@isuru === “activity” means nothing here: suppress it.

Thanks for replying me,
I checked both fragment.setView(frame, this); and fragment.setView(frame, MainActivity.this);

The same error comes

Thanks for replying me.

That ‘activity’ is just the hint given by android studio.
I cannot keep that 2nd argument empty it prompts me to give an activity

@isuru === yes, i know, that is a hint, but the error is not here, it is from your imports (see the line which explains the error); you are importing androidx why not “import”? BTW what is your version of android mode? How have you modified the main activity? how have you imported your P5 sketch inside AS?

1 Like

Hi I changed the AppCompactActivity import to FragmentActivity the error is still showing but the program worked without any problems

Thanks very much

1 Like

@isuru ===

hapy that it works; yet (as i want to understand exactly!!!) can you put now the complete code of your mainactivity??? - And also tell wether you are targetting 28 or 29: put the gradle files from your build.

This is the gradle file

This is the main activity

Targeting API is 29 therefore I cannot use packages instead of that I had to use andoidX packages.
I think the error is still showing there because they have not updated the processing.core.jar to support the new androidx packages but since the content of androidx and support.v4 packages are same the program worked without any problems.
Thanks for Helping me.

1 Like

@isuru ===
ok, now i understand, you are targetting 29 and the standard appCompat is for 28 (or less!) and i agree with you: the error seems to be related to P5, more precisely to PFragment which (i suppose) uses the “old” support.

1 Like

Hi @isuru

I’m having the same issue. Yes, the code works but it’s very annoying to have that error showing all the time. Did you find a solution?



Hi there

Noticing the same issue here.
I’m wondering if you found a fix


The latest solves the issue