Android Constraint Layout


(Bee Jay) #1

Everytime I’m using ConstraintLayout on my Silver/Fire project, I got this error…

There’s no problem if I use other layouts.

Any hints?

Thank you.


(marc hoffman) #2

does the error get caught when you hit Continue Running, or does the app fail?

(Bee Jay) #3

It get caught everytime I hit the “Continue Running” button. When I run the app directly on the device, the app just crashes.

(marc hoffman) #4

Ok. then i guess something is missing, maybe you need a coot-local reference in order to get the ContainedLayout class? i’m not familiar with the class, specifically.

(marc hoffman) #5

(how) do you reference the` package?

(Bee Jay) #6

I edit the layout xml file in Android Studio, change the main view layout to ConstraintLayout. That’s all. It works with other kind of layout, but fails if and only if I change it to ConstraintLayout.

(marc hoffman) #7

right. because the ConstraintLayout class isn’t part of the base SDK, you need to add a reference to the package i mentioned above, via Add Reference|Gradle References.

(Bee Jay) #8

I’ve looked at the gradle’s references, but I couldn’t find the required package for Constraint Layout.

So, as explained here:

I’ve added required addition to the project’s build.gradle file, but when I sync it on Android studio, it complains with this error…

I followed all the given instructions but the sync process still failed with more errors that I couldn’t resolve. And, now I’m stuck.

Android development isn’t as easy as iOS, I suppose. :slight_smile:

(Bee Jay) #9

Alright… now I can sync the build.gradle file. But, I still can’t find the required package for Constraint layout to be included in Fire’s project. I’ve been browsing all the gradle folders. Stucked again. :smiley:

(marc hoffman) #10

i don’t see it in the list either, you’ll need to add it manually for now.

add <GradeReference Include="*" > to your project file.

(Bee Jay) #11

I did it (with typo fixed). Then Android Studio seemed to download and install something, I don’t know. To make sure everything was installed correctly, I restarted the Android Studio app. Then I tried to edit my app UI layout again, through the Fire’s “Edit UI files in Android Studio” menu. Strangely, the Android Studio just opened the main-layout.xml file but didn’t show its UI builder. As if it didn’t understand what to do with the file.

I’m confused. Stucked again. :smiley:

(marc hoffman) #12

I don’t see what ADS has to do with this reference, it shouldn’t affect it or see it. Send me our project, and i can have look, but really these are standard Android development pains, not really Fire/Elements issues at this stage.

(Bee Jay) #13

Yes, I realized that as well. But as I’m using Fire and newbie with Android dev, I might ask about it here too. Might someone is able to help me or gives me some hints. I apologize if it’s not allowed here.

As last resort, I just deleted my Fire project, re-installed Android Studio, and everything back to normal again. I know it’s silly and not an elegant effort, but it works. :grinning:

I no longer care to use Constraint Layout again. But I suggest Fire to support it out of the box because although it’s not official, it’s encouraged to be used. Even on the official Android tutorials, they’re using Constraint Layout which I think weird as it’s not included in official Android SDK.

(marc hoffman) #14

It does?

(Bee Jay) #15

Nope, my experience showed that Fire failed to compile my project if I use constraint layout. I still need to do something manually, which unfortunately didn’t work either. I wish it could be as simple as ticking a check mark in Gradle references dialog, or something like that.

(marc hoffman) #16

well, because you need the reference. theres a million optional packages you can reference, we can’t add them all by default or your app would be 5 GB in size and take 3 hours to build.

it still doesn’t work after you add the reference?

it should be, i don’t know why it’s not listed. the list of packages is to maintained by us, its obtained from the repository. But i’ll investigate. What version of the SDK do you have installed?

(Bee Jay) #17

I didn’t ask you to add all available packages. Just some of them that are encouraged by Google. Constraint Layout is one of them, I don’t know the other elses yet.

There’s no new reference added into the list that I can pick from.

SDK 25 for Android 5.1.

(marc hoffman) #18

Not gonna happen. i’m not goal pollute every project template with external references people might maybe eventually* wanna use, buy default.

right, and i told you the workaround for that.

(Bee Jay) #19

Alright then. You’re the boss. Just so you know, regarding Constraint Layout… people not might eventually use it, but people will use it because Google encourages it. Take a look at this official Android Developers Training page: titled Best Practive for UI which clearly mentions not Linear Layout, not Relative Layout, not anything else, but Constraint Layout. Well, perhaps people don’t read that page anyway.

Yes, thank you but it didn’t work. So I simply ignore Constraint Layout altogether so I can move on further learning Swift and Android. It’s alright.

(marc hoffman) #20

There’s literally thousands of external APIs Google provided and “encourages” to use. That’s what references are for. doesn’t;t mean they should all be referenced by default.

Ok, but i can’t diagnose further from “that didn’t work”; i’d need a little more than that :(.