Muhammad Alfaifi
Muhammad Alfaifi

Reputation: 5702

Failed linking file resources when using Motion Layout KeyPosition

I am getting

"Failed linking file resources"

with

"error: attribute type (aka com.testapp.client:type) not found"

When using the new MotionLayout, specifically when adding a KeyPosition element to the scene file.

My scene file for reference:

<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<Transition
    app:constraintSetEnd="@id/collapsed"
    app:constraintSetStart="@id/expanded">

    <OnSwipe
        app:dragDirection="dragUp"
        app:touchAnchorId="@id/recyclerview"
        app:touchAnchorSide="top" />

    <KeyFrameSet>
        <KeyAttribute
            app:framePosition="60"
            app:target="@id/toolbar_image">
            <CustomAttribute
                app:attributeName="imageAlpha"
                app:customIntegerValue="255" />
        </KeyAttribute>
        <KeyAttribute
            app:framePosition="90"
            app:target="@id/toolbar_image">
            <CustomAttribute
                app:attributeName="imageAlpha"
                app:customIntegerValue="0" />
        </KeyAttribute>
        <KeyPosition
            app:type="pathRelative"
            app:framePosition="50"
            app:target="@id/title"
            app:percentX="0.9" />
    </KeyFrameSet>
</Transition>

<ConstraintSet android:id="@+id/expanded">
    <Constraint
        android:id="@id/toolbar_image"
        android:layout_height="200dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <Constraint
        android:id="@id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginBottom="24dp"
        android:scaleX="1.0"
        android:scaleY="1.0"
        app:layout_constraintBottom_toBottomOf="@id/toolbar_image"
        app:layout_constraintStart_toStartOf="parent" />
</ConstraintSet>

<ConstraintSet android:id="@+id/collapsed">
    <Constraint
        android:id="@id/toolbar_image"
        android:layout_height="?attr/actionBarSize"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <Constraint
        android:id="@id/title"
        android:layout_marginStart="20dp"
        android:layout_marginBottom="0dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleX="0.625"
        android:scaleY="0.625"
        app:layout_constraintBottom_toBottomOf="@id/toolbar_image"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/toolbar_image" />

</ConstraintSet>

I am using Android Studio 3.2 stable, and AndroidX varients of the support libs & constraint layout.

Any help is appreciated :)

Upvotes: 3

Views: 2924

Answers (3)

kaushalyap
kaushalyap

Reputation: 13617

Update:

As @MichałK mentioned in comments in seems to be that

android:interpolator have changed to motion:motionInterpolator

in a later version

Reference: https://developer.android.com/reference/android/support/constraint/motion/MotionLayout.html#transition


Old Post:

In addition to what @Momen mentioned

In <Transition ...> tag motion:interpolator

have been changed to android:interpolator

( Change of namespace from motion to android )

example:

<Transition ...
    android:interpolator="@android:anim/accelerate_interpolator">

Upvotes: 1

Momen Zaqout
Momen Zaqout

Reputation: 1498

For your information, target

has been changed to motionTarget

in KeyPosition and KeyAttribute

Upvotes: 13

Muhammad Alfaifi
Muhammad Alfaifi

Reputation: 5702

Nevermind :)

Attribute "type" on KeyPosition element has been changed in Alpha 2 to be "keyPositionType"

here is a snippet if anyone is having the same issues:

        <KeyPosition
            app:keyPositionType="pathRelative"
            app:framePosition="50"
            app:target="@id/title"
            app:percentX="0.9" />

instead of this:

        <KeyPosition
            app:type="pathRelative"
            app:framePosition="50"
            app:target="@id/title"
            app:percentX="0.9" />

Upvotes: 12

Related Questions