Expected resource of type animator [ResourceType]

Marcin Kunert

I've updated my SDK to the newest version, but now I am getting a lint error.

Error: Expected resource of type animator [ResourceType]

The error occurs on this line:

AnimatorInflater.loadAnimator(context, R.anim.right_slide_in)

The referenced resource /res/anim/right_slide_in.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:valueTo="0"
    android:valueFrom="1.0"
    android:propertyName="xFraction"
    android:valueType="floatType"
    android:duration="450" />

It always worked before. Could somebody explain why I am getting that error?

Xaver Kapeller

The error occurs because you store your Animator resources in the wrong directory! It worked before because the AnimatorInflater can load the xml regardless of in which folder it is saved.

  • R.anim.* resources from the res/anim/ folder are for view animations.
  • R.animator.* resources from the /res/animator/ folder are for Animators.

So to fix the error just move your Animator resources from /res/anim/ to /res/animator/.


This used to make no difference at all until the resource type annotations were added to the support library. A long with those annotations there also were many new lint checks among others the one which tripped you up.

In the future if you get an error like this you can look at the annotation to figure out what you are doing wrong. For example the implementation of loadAnimator() of the AnimatorInflater looks like this:

public static Animator loadAnimator(Context context, @AnimatorRes int id)
        throws NotFoundException {
    return loadAnimator(context.getResources(), context.getTheme(), id);
}

The @AnimatorRes annotation on the id parameter indicates that only Animator resources should be passed here. If you look at the documentation of @AnimatorRes it reads like this:

Denotes that an integer parameter, field or method return value is expected to be an animator resource reference (e.g. android.R.animator.fade_in).

If the description doesn't explain the error already, then the example usually does ;)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

WARN in logcat ResourceType: For resource ..., entry index(...) is beyond type entryCount(1)

分類Dev

Program type already present: com.nineoldandroids.animation.Animator

分類Dev

No type arguments expected for class Call

分類Dev

Couldn't match expected type `[a]' with actual type `a'

分類Dev

Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected

分類Dev

Error in resource configuration. Expected response to contain an object but got an array

分類Dev

No '|' candidates produce the expected contextual result type 'NSTextStorageEditActions'

分類Dev

RestKit - Expected Content Type application/json

分類Dev

TypeScript function passes type check when not expected to

分類Dev

Invariant Violation: Element type is invalid: expected a string

分類Dev

Redux store: Element type is invalid: expected a string

分類Dev

Haskell couldn't match weird expected type

分類Dev

RuntimeError: expected scalar type Long but found Float

分類Dev

Assignment: this expression was expected to have the type unit

分類Dev

Change Animator Controller by Script

分類Dev

Argument type 'Int' does not conform to expected type 'NSCoding & NSCopying & NSObjectProtocol'

分類Dev

Haskell - Couldn't match expected type ‘b’ with actual type ‘a’

分類Dev

Cannot convert value of type '(_) -> ()' to expected argument type '((Bool, Error?) -> Void)?'

分類Dev

Scala Pattern Matching returns expected type but generates type mismatch afterwards

分類Dev

Cannot convert value of type 'String' to expected argument type '_?'

分類Dev

Expected 'property' to be of type string, instead found type object - Dynamoose

分類Dev

AngularJS: Error in resource configuration for action `query`. Expected response to contain an object but got an array

分類Dev

Navigation Architecture Component - New Resource dialog doesn't have Navigation resource type for navigation graph

分類Dev

rspec-puppet unit test for define type using resource

分類Dev

How to detect the type of a transaction: JTA or Resource Local from java code?

分類Dev

Cloudinary、Carrierwave-resource_typeをrawに設定

分類Dev

VS 2008 resource type error while changing language

分類Dev

JAX-RS Custom JSON representation of primitive Resource return type

分類Dev

What does () mean as an argument in a function where a parameter of type T is expected?

Related 関連記事

  1. 1

    WARN in logcat ResourceType: For resource ..., entry index(...) is beyond type entryCount(1)

  2. 2

    Program type already present: com.nineoldandroids.animation.Animator

  3. 3

    No type arguments expected for class Call

  4. 4

    Couldn't match expected type `[a]' with actual type `a'

  5. 5

    Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected

  6. 6

    Error in resource configuration. Expected response to contain an object but got an array

  7. 7

    No '|' candidates produce the expected contextual result type 'NSTextStorageEditActions'

  8. 8

    RestKit - Expected Content Type application/json

  9. 9

    TypeScript function passes type check when not expected to

  10. 10

    Invariant Violation: Element type is invalid: expected a string

  11. 11

    Redux store: Element type is invalid: expected a string

  12. 12

    Haskell couldn't match weird expected type

  13. 13

    RuntimeError: expected scalar type Long but found Float

  14. 14

    Assignment: this expression was expected to have the type unit

  15. 15

    Change Animator Controller by Script

  16. 16

    Argument type 'Int' does not conform to expected type 'NSCoding & NSCopying & NSObjectProtocol'

  17. 17

    Haskell - Couldn't match expected type ‘b’ with actual type ‘a’

  18. 18

    Cannot convert value of type '(_) -> ()' to expected argument type '((Bool, Error?) -> Void)?'

  19. 19

    Scala Pattern Matching returns expected type but generates type mismatch afterwards

  20. 20

    Cannot convert value of type 'String' to expected argument type '_?'

  21. 21

    Expected 'property' to be of type string, instead found type object - Dynamoose

  22. 22

    AngularJS: Error in resource configuration for action `query`. Expected response to contain an object but got an array

  23. 23

    Navigation Architecture Component - New Resource dialog doesn't have Navigation resource type for navigation graph

  24. 24

    rspec-puppet unit test for define type using resource

  25. 25

    How to detect the type of a transaction: JTA or Resource Local from java code?

  26. 26

    Cloudinary、Carrierwave-resource_typeをrawに設定

  27. 27

    VS 2008 resource type error while changing language

  28. 28

    JAX-RS Custom JSON representation of primitive Resource return type

  29. 29

    What does () mean as an argument in a function where a parameter of type T is expected?

ホットタグ

アーカイブ