Hi Advaith, your app is really nice! it works fine on my Android phone. Unfortunately when I run it on the Emulator or on iOS phones it doesn't work. I guess this is because of extensions? If so, could you please simplify it so that it works (of course less nice than on Android) on the Emulator (or iOS) too? I tried removing all extensions (very crude hack, I know) and I get errors about activating a "constraint with anchors and because they have no common ancestor". I guess this is because of the components I removed. Can you help me?
Sorry, No one can run the app's aia with ios or the emulator. Why?
- the app uses a Pedometer control. The emulator cannot emulate hardware and count steps etc.
- the app uses extensions. The ios version of App Inventor can not use Android extensions.
Thanks for your answer @SteveJG. I removed the pedometer too and now it works on the emulator (of course, it doesn't do much, but at least I can see the interface). But, even if there are no extensions now, I keep getting the same error "constraint with anchors and because they have no common ancestor" when I try to run it on the AI2 Companion for iOS.
It would be enough for me to be able to show my students even a simplified UI (I know that pedometers works on iOS). Can someone tell me why I get this error "constraint with anchors and because they have no common ancestor" on iOS even after removing all Android extensions? Thanks in advance for your help.
This simple pedometer works on my Android 12. Try the aia on ios and see what happens? It should work (sorry, I do not have ios to test).
See the Pedometer documentation for an explanation of the Save/Reset buttons.
PedometerExample.aia (2.7 KB)
Does the example pedometer work on your ios ? Remember, ios App Inventor currently cannot build the app for installation. Once you run the app you possibly have to stay in range of your WIFI connection for the example to work. (Difficult if you walk around to test ) Let us know what happens please.
I tried it now. I can see the UI, but the text of label1 doesn't change when I click start and walk around. Anyway, this is not what worries me. I would like to be able to see the UI of the "Exercise Mate" app on iOS, even after removing everything that bothers it. I removed all extensions, and the pedometer sensor too. But, when I load the project in AI Companion, the iphone screen starts flashing and App Inventor shows the "constraint with anchors and because they have no common ancestor" error until I close the AI Companion app.
The full error is "error: Unable to activate constraint with anchors and because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.."
Your experience suggests that the Pedometer control does not yet work with the ios version of App Inventor.
You have to wait until MIT fixes this apparent bug.
you have issues with is in regards to the Exercise Mate App Showcase. Not the simple Pedometer example
The error you get with Exercise Mate implies something in the author's GUI is also incompatible with with ios AI. What? You have to modify the app and see if you can gete it running without the extensions.
Simply, you cannot use the Exercise Mate example with ios and your students.
This is what I tried. But the error "Unable to activate constraint with anchors and because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.." shows up after I removed all extensions and the pedometer too.
This discussion indicates part of your issue may be the Layouts/Arrangements
What is weird (at least to me) is that the app works fine in Android
When I open the app in my iphone 13 and walk around, the two labels keep saying 0. Instead, when I load the app in my (very old) Android phone, the two labels change as soon as I move around.
I merged your topics. Please don't double post.
App Inventor for ios does not presently work with the Pedometer. There is nothing you can do until MIT can provide a solution. What controls work on Android devices does not necessarily work correctly with ios as you discovered.
This is not weird, it is because ios App Inventor still has LOTS of bugs. Realistically, App Inventor for ios is probably never going to work with all the tools available for Android users. This is a fact of life because the two operating systems are different and each has different requirements.
Be happy that the Pedometer works with Android. Some day it will work with ios. When? Next month or next year but not now.
Sorry, I didn't mean double posting. I forgot to add a link to a minimal non working project, MIT App Inventor Gallery
There are two things to untangle here. The issue related to the constraint activation is a known issue in the layout engine that we are working to resolve. It has to do with the use of Fill Parent or percentage sizing of invisible components. You can either switch to absolute sizing of the components, or not make them invisible at the start of the app. Extensions are all non-visible (they aren't part of the view hierarchy) and also are not supported on iOS.
For the pedometer counting issue, I'm not sure what's going on here as the code is implemented and did work at the time it was merged. I'll build a small test app and see if I can understand the root cause. Which version of iOS are you using?
Edit: So I created a very simple app and it appears to work, although it is extremely particular about what it is counting as a step. Internally, we're using the Apple CoreMotion library to manage the step detection and we may need to adjust its sensitivity to give more reasonable step counts.
Do you think using screens instead of visible/invisible layouts would work?
Would you share it so I can test it?
Here it is.
PedometerTest.aia (1.9 KB)
As I mentioned, I had to make very exaggerated movements for it to work, so my guess is there is an issue somewhere in the calculation of how strong a signal a step should be.