Error resolving Gradle reference

I am encountering a fatal build error trying to resolve a reference for recent versions of Google’s ConstraintLayout library for Android. The most recent stable versions are 2.0.1, 2.0.0, and 1.1.3. I am able to build using 1.1.3 but not for 2.0.+. (But I have to use 2.0.+, since when I reference 1.1.3 in my main project, I get a “missing method” runtime error on a method that is apparently referenced by a different library I include).

Here is a sample project. It’s a clean new project with only a reference to the ConstraintLayout library added. As it stands, it generates 4 build errors “attibute ___ has already been defined”. Seems like possibly a merging issue? Reverting the gradle reference to 1.1.3 causes the errors to go away. (29.3 KB)

FWIW< the reference resolves fine for me?

Doesn’t look like it, as this happens on AAPT, long before we merge the manifest. this is the offending XM<:

    <declare-styleable name="PropertySet"><attr name="android:visibility"/><attr name="visibilityMode"/><attr format="float" name="android:alpha"/><attr name="motionProgress"/><attr name="layout_constraintTag"/></declare-styleable> //  aapt: Attribute "android:alpha" has already been defined
    <declare-styleable name="Transform"><attr name="android:elevation"/><attr name="android:rotation"/><attr name="android:rotationX"/><attr name="android:rotationY"/><attr name="android:scaleX"/><attr name="android:scaleY"/><attr name="android:transformPivotX"/><attr name="android:transformPivotY"/><attr format="dimension" name="android:translationX"/><attr format="dimension" name="android:translationY"/><attr format="dimension" name="android:translationZ"/></declare-styleable> //  aapt: Attribute "android:translationX" has already been defined
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    //  aapt: Attribute "android:translationY" has already been defined
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    //  aapt: Attribute "android:translationZ" has already been defined

from /Debug/Cooper-Android/aar/constraintlayout-2.0.0/res/values/values.xml

I’m guessing constraintlayout-2.0.0 is not compatible with androidx, as this seems reminiscent of many errors I have seen when mixing legacy APIs with androidx. But thats just a guess.

Ah sorry for the confusion - the references resolve fine for me, the error is with building the project.

And the ConstraintLayout I’m using is actually an AndroidX library, and so are the other references (although this is the only reference in my sample project).

I think I did determine the cause of the “method not found” error that prevents me from reverting to 1.1.3. When I revert to 1.1.3, constraintlayout requests constraintlayout-solver 1.1.3 but it resolves to 2.0.1. The method not found exception is

java.lang.NoSuchMethodError: No virtual method setWrapWidth(I)V in class Landroidx/constraintlayout/solver/widgets/ConstraintWidget; or its super classes (declaration of 'androidx.constraintlayout.solver.widgets.ConstraintWidget' appears in /data/app/~~6ZjXfVg7V1iyQtNqAdM0kg==/com.accordancebible.accordance-D1YSy9bMkXDJaIrM5lbUxg==/base.apk!classes18.dex)

It looks like constraintlayout 1.1.3 still pulls in constraintlayout-solver 2.0.1 internally, and constraintlayout-solver 2.0.1 is attempting to reference a method from constraintlayout 2.0.1 that did not exist in 1.1.3.


I suppose if I use the brackets to hard-limit which version a reference pulls, I would also want its references hard-limited as well, right? In this case I would at least need the option to do so.

[ removed comment - see below ]

Ah wait, there is a constraintlayout-solver package in my Ebuild/Packges/Gradle folder, just not in my intermediates folder. I have versions 1.1.3 and 2.0.1 in my local gradle folder, but it looks like neither is being pulled into the build although the build seems to expect it…

It looks like the ultimate cause of the issue is that the jar for constraintlayout-solver version 2.0.1 is pulled in instead of version 1.1.3, when I requested constraintlayout 1.1.3.

Confirmed this is the issue. I at least have my build working for now, by copying my constaintlayout-solver:1.1.3 gradle cache folder to 2.0.1 so the correct one is pulled in.