# Processing with Android Studio Error in fragment.setView arguments

**URL:** <https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860>\
**Category:** Processing for Android\
**Created:** [March 21, 2020, 5:04am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860 "2020-03-21T05:04:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![isuru](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@isuru](https://discourse.processing.org/u/isuru)\
**Post date:** [March 21, 2020, 5:04am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/1 "2020-03-21T05:04:43Z")

</div>

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

 ![Error](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7d8c4378533bfa26d596d0c69f9f50bfd69157a2.png)

Wrong 2nd argument in the fragment.setView method

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [March 21, 2020, 6:59am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/2 "2020-03-21T06:59:14Z")

</div>

Hi @isuru  
What happens if you just use:

```auto
fragment.setView(frame, this);

```

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [March 21, 2020, 9:27am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/3 "2020-03-21T09:27:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![isuru](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@isuru](https://discourse.processing.org/u/isuru)\
**Post date:** [March 21, 2020, 10:12am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/4 "2020-03-21T10:12:51Z")

</div>

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

The same error comes

---

<div class="post-metadata">

**Author:** ![isuru](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@isuru](https://discourse.processing.org/u/isuru)\
**Post date:** [March 21, 2020, 10:16am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/5 "2020-03-21T10:16:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [March 21, 2020, 11:31am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/6 "2020-03-21T11:31:13Z")

</div>

@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 android.support.v7.app.AppCompatActivity”? BTW what is your version of android mode? How have you modified the main activity? how have you imported your P5 sketch inside AS?

---

<div class="post-metadata">

**Author:** ![isuru](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@isuru](https://discourse.processing.org/u/isuru)\
**Post date:** [March 21, 2020, 2:32pm UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/7 "2020-03-21T14:32:11Z")

</div>

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

Thanks very much

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [March 21, 2020, 2:40pm UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/8 "2020-03-21T14:40:42Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![isuru](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@isuru](https://discourse.processing.org/u/isuru)\
**Post date:** [March 22, 2020, 2:47am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/9 "2020-03-22T02:47:54Z")

</div>

This is the gradle file

 ![gradle file](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b78de74e6097010b06e5b81dc2a1bf088572849d.jpeg)  
…

This is the main activity

 ![mainActivity1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5632bee271859e129cbcfe3a12d136b2c5ae8f6b.jpeg)  
 ![mainActivity2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9569a6056fea20c69daa7d3ea9dd39095a5a12ff.jpeg)

Targeting API is 29 therefore I cannot use android.support.v4 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.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [March 22, 2020, 9:19am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/10 "2020-03-22T09:19:03Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![SMD](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@SMD](https://discourse.processing.org/u/SMD)\
**Post date:** [June 6, 2020, 3:44pm UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/11 "2020-06-06T15:44:31Z")

</div>

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?

Thanks

Simon

---

<div class="post-metadata">

**Author:** ![phoebus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/phoebus/32/481_2.png) [@phoebus](https://discourse.processing.org/u/phoebus)\
**Post date:** [July 19, 2021, 4:52am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/12 "2021-07-19T04:52:09Z")

</div>

Hi there

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

cheers

---

<div class="post-metadata">

**Author:** ![phoebus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/phoebus/32/481_2.png) [@phoebus](https://discourse.processing.org/u/phoebus)\
**Post date:** [July 23, 2021, 5:21am UTC](https://discourse.processing.org/t/processing-with-android-studio-error-in-fragment-setview-arguments/18860/13 "2021-07-23T05:21:13Z")

</div>

The latest processing-core.zip solves the issue
