# Build errors on Android - "JUCE\_MODAL\_LOOPS\_PERMITTED" macro

**URL:** <https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412>\
**Category:** Android\
**Created:** [June 8, 2021, 5:11pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412 "2021-06-08T17:11:57Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![jucedev84](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jucedev84](https://forum.juce.com/u/jucedev84)\
**Post date:** [June 8, 2021, 5:11pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/1 "2021-06-08T17:11:57Z")

</div>

Hello Team,

Thanks for your support in advance.

We are exploring JUCE Framework and it’s usage for developing plugin’s…etc

We have developed sample plugin’s using JUCE Framework.

**JUCE claims that same source code developed on one platform can be ported onto other platforms without any changes.**

Hence we have ported plugin developed for windows platform onto Android platform.

But we have end up with build errors w.r.t functions supported **under “**  **JUCE\_MODAL\_LOOPS\_PERMITTED == 1”.**

**Note: For Android platform, this macro “JUCE\_MODAL\_LOOPS\_PERMITTED == 0”.**

Android platform build errors for below discussed functions:

**’juce::FileChooser::browseForFileToOpen() & juce::FileChooser::browseForFileToSave()’**

By referring to below link we understood that this is due to Android compatible issues.

[Build errors for Android not seen in win/osx/iOS - Android - JUCE](https://forum.juce.com/t/build-errors-for-android-not-seen-in-win-osx-ios/20886/3)

Kindly support us to resolve the above errors on Android platform without doing any code modifications.

Best Regards,

GeethaP.

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [June 8, 2021, 5:14pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/2 "2021-06-08T17:14:41Z")

</div>

Hi, you’re going to need to change code I’m afraid. I know this is frustrating as I went through the same process a few years ago.

Android doesn’t allow modal loops so everything has to be done via async launching of dialogs which can be launched sync on other platforms.

I guess that the claim is correct if you happened to write everything async in the first place, but if you didn’t then changes will need to be made.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [June 8, 2021, 5:44pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/3 "2021-06-08T17:44:35Z")

</div>

I think @leehu covered all the important points. Modal loops are completely unsupported on Android, so code that uses modal loops cannot be ported. Code that was written with modal loops disabled from the outset should be portable with no additional changes.

For the most part, modal functions have asynchronous equivalents, and it should be reasonably straightforward to convert modal code to be asynchronous.

In a future release of JUCE, we are planning to set `JUCE_MODAL_LOOPS_PERMITTED` to zero on all platforms by default, which should make it easier to write completely portable code. Of course, it will still be possible to enable modal loops on platforms that support this feature, for backwards compatibility.

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [July 2, 2021, 6:08pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/5 "2021-07-02T18:08:42Z")

</div>

Hi. I presume this has been done now as I have some compilation issues with latest pull.  
Is there any help on how to rewrite our existing code, e.g.

```
            juce::CallOutBox callOut (colourSelector, getScreenBounds(), nullptr);
            callOut.runModalLoop();

            value = colourSelector.getCurrentColour();

```

thx

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [July 2, 2021, 6:09pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/6 "2021-07-02T18:09:16Z")

</div>

Yes, this change is mentioned in the BREAKING CHANGES doc in the repository.

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [July 2, 2021, 6:11pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/7 "2021-07-02T18:11:47Z")

</div>

hi - thx. yes, have seen that. sorry, some of the text got missed form my last post as I wondered if there are any hints anywhere as to how to rewrite existing code, such as the bit I provided, without using modal loops?

thx

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [July 2, 2021, 6:23pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/8 "2021-07-02T18:23:26Z")

</div>

The example projects (e.g. the WidgetsDemo) shows how to use `CallOutBox::launchAsynchronously`, and the class docs for CallOutBox has a code snippet showing how this function can be used.

@tpoole updated all of the demo projects to avoid modal loops, so those are probably a good place to start if you’re unsure how to rewrite usages of modal functions.

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [July 2, 2021, 6:24pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/9 "2021-07-02T18:24:52Z")

</div>

great, thanks.

Just realised it’s gin code. Will see if that’s been updated yet - will have to reenable the flag until then.

@Toddler-Boy hi - are there any plans to update the gin library so it builds without the JUCE\_MODAL\_LOOPS\_PERMITTED flag set to 1? thx

---

<div class="post-metadata">

**Author:** ![Toddler-Boy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/toddler-boy/32/2007_2.png) [@Toddler-Boy](https://forum.juce.com/u/Toddler-Boy)\
**Post date:** [July 2, 2021, 7:02pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/10 "2021-07-02T19:02:50Z")

</div>

That’s more a job for @FigBug, since he wrote Gin. I assume that this will happen rather sooner than later. We are using Gin, but mainly for the Image functions and some odds and ends.

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [July 2, 2021, 7:04pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/11 "2021-07-02T19:04:38Z")

</div>

ah, thx. Mainly image functions for me also.

---

<div class="post-metadata">

**Author:** ![Toddler-Boy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/toddler-boy/32/2007_2.png) [@Toddler-Boy](https://forum.juce.com/u/Toddler-Boy)\
**Post date:** [July 2, 2021, 7:39pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/12 "2021-07-02T19:39:13Z")

</div>

Which function is giving you the compiler error?

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [July 2, 2021, 7:41pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/13 "2021-07-02T19:41:05Z")

</div>

Theres a couple of calls to FileChooser::browseForDirectory() and a call to PopupMenu::show().

---

<div class="post-metadata">

**Author:** ![Toddler-Boy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/toddler-boy/32/2007_2.png) [@Toddler-Boy](https://forum.juce.com/u/Toddler-Boy)\
**Post date:** [July 2, 2021, 7:53pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/14 "2021-07-02T19:53:19Z")

</div>

I can’t find any instances of PopupMenu::show in Gin. They all using ::showMenuAsync

---

<div class="post-metadata">

**Author:** ![Toddler-Boy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/toddler-boy/32/2007_2.png) [@Toddler-Boy](https://forum.juce.com/u/Toddler-Boy)\
**Post date:** [July 2, 2021, 7:53pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/15 "2021-07-02T19:53:48Z")

</div>

> [@leehu](#):
>
> browseForDirectory

Gin doesn’t have a call to that.

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [July 2, 2021, 8:01pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/16 "2021-07-02T20:01:02Z")

</div>

I thought I fixed the issues here: [Support modal loops · FigBug/Gin@f5a4d89 · GitHub](https://github.com/FigBug/Gin/commit/f5a4d8989e072140cf51e75c3349349fefd75e13)

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [July 2, 2021, 8:07pm UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/17 "2021-07-02T20:07:57Z")

</div>

I may have an old repo - will refresh it. thx

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [July 3, 2021, 10:47am UTC](https://forum.juce.com/t/build-errors-on-android-juce-modal-loops-permitted-macro/46412/18 "2021-07-03T10:47:42Z")

</div>

Hi - that was it, I had an old repo. thx.
