简体   繁体   中英

Android Motionlayout: Android resource linking failed

I keep getting build errors after a refactor to motionlayout 2.0.0-beta1 (I know it's not the newest version - beta2 produces same errors).

Here's the stacktrace:

AAPT: /Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6514: error: resource attr/flow_horizontalSeparator (aka com.example:attr/flow_horizontalSeparator) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6514: error: resource attr/flow_verticalSeparator (aka com.example:attr/flow_verticalSeparator) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6515: error: resource attr/flow_horizontalSeparator (aka com.example:attr/flow_horizontalSeparator) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6515: error: resource attr/flow_verticalSeparator (aka com.example:attr/flow_verticalSeparator) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6517: error: resource attr/flow_horizontalSeparator (aka com.example:attr/flow_horizontalSeparator) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6517: error: resource attr/flow_verticalSeparator (aka com.example:attr/flow_verticalSeparator) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6517: error: resource attr/motionProgress (aka com.example:attr/motionProgress) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6860: error: resource attr/motionProgress (aka com.example:attr/motionProgress) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6861: error: resource attr/motionProgress (aka com.example:attr/motionProgress) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6876: error: resource attr/motionProgress (aka com.example:attr/motionProgress) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6877: error: resource attr/motionProgress (aka com.example:attr/motionProgress) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:6877: error: resource attr/waveDecay (aka com.example:attr/waveDecay) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:7288: error: resource attr/motionPathRotate (aka com.example:attr/motionPathRotate) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:7290: error: resource attr/motionProgress (aka com.example:attr/motionProgress) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:7549: error: resource attr/motionProgress (aka com.example:attr/motionProgress) not found.
/Users/TBS/StudioProjects/ExampleApp/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:8270: error: resource attr/duration (aka com.example:attr/duration) not found.
error: failed linking references.

There's no indication as to what file produces the error and to my knowledge I don't use any of these attributes anywhere in my project.

This problem is related to Android Studio 3.6 and ConstraintLayout versions earlier than 2.0.0-beta3 - I've reported the issue here . This is fixed in ConstraintLayout 2.0.0-beta3.

Android Studio 3.5 doesn't produce this error.

To make it work in AS 3.6 beta, upgrade to ConstraintLayout 2.0.0-beta3 or later.

If even upgrading ConstraintLayout doesn't help, try to add format attribute to your attr declaration in your attrs.xml file.

<resources>
    <attr name="yourAttrName" format="string" />
</resources>

Choose proper format for your attribute.

upgrading to constraintlayout:2.0.0-beta4, worked for me , or later version. This happens after you upgrade android studio to 3.6

我将 gradle 版本升级到com.android.tools.build:gradle:3.6.0然后遇到了这个问题,只需将 gradle 版本降级到com.android.tools.build:gradle:3.5.3问题就解决了

You would have to do two things:

  1. Update your android studio.

  2. add Latest dependency implementation

    'androidx.constraintlayout:constraintlayout:2.0.0-rc1'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM