kedzie / Support_v4_NineOldAndroids

75 stars 17 forks source link

Resources$NotFoundException when using custom animations for FragmentTransaction #3

Closed tomkoptel closed 11 years ago

tomkoptel commented 11 years ago

Hello!

I'm facing force close on my device which runs android 2.3.4 When I'm launching fragment custom transactions app closes with Resources$NotFoundException.

I guess the reason of this is incorrect integration of your lib inside the project. Can you take a look whether my pom.xml installation correct and if yes, what is your suggestion about the error log below.

Many thanks!

Here is my pom.xml:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.6</java.version>
    <android.version>4.1.1.4</android.version>
    <android.platform>17</android.platform>
    <!--3-d Party Dependencies-->
    <android.support.v4.animator>13.0.0</android.support.v4.animator>
    <android.viewpagerindicator>2.4.1</android.viewpagerindicator>
    <android.mottimotti>1.0.7</android.mottimotti>
    <android.androidannotations>2.7</android.androidannotations>
    <android.universalimageloader>1.8.6</android.universalimageloader>
    <android.robospice.spring>1.4.6</android.robospice.spring>
    <android.robospice.ormlite>1.4.6</android.robospice.ormlite>
    <android.tojc.ormlite>1.0.2</android.tojc.ormlite>
    <android.nineolds>2.4.0</android.nineolds>
    <android.joda.time>2.3</android.joda.time>
</properties>

<dependencies>

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.nineoldandroids</groupId>
        <artifactId>library</artifactId>
        <version>2.4.0</version>
        <type>jar</type>
    </dependency>

    <dependency>
        <groupId>com.github.kedzie.supportanimator</groupId>
        <artifactId>support-v4-animator</artifactId>
        <version>${android.support.v4.animator}</version>
        <type>apklib</type>
    </dependency>

    <dependency>
        <groupId>com.viewpagerindicator</groupId>
        <artifactId>library</artifactId>
        <version>${android.viewpagerindicator}</version>
        <type>apklib</type>
        <exclusions>
            <exclusion>
                <groupId>com.google.android</groupId>
                <artifactId>support-v4</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.mottimotti.android</groupId>
        <artifactId>library</artifactId>
        <version>${android.mottimotti}</version>
        <type>apklib</type>
        <exclusions>
            <exclusion>
                <groupId>com.google.android</groupId>
                <artifactId>support-v4</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.googlecode.androidannotations</groupId>
        <artifactId>androidannotations</artifactId>
        <version>${android.androidannotations}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.googlecode.androidannotations</groupId>
        <artifactId>androidannotations-api</artifactId>
        <version>${android.androidannotations}</version>
    </dependency>

    <dependency>
        <groupId>com.nostra13.universalimageloader</groupId>
        <artifactId>universal-image-loader</artifactId>
        <version>${android.universalimageloader}</version>
    </dependency>

    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-spring-android</artifactId>
        <version>${android.robospice.spring}</version>
    </dependency>

    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-ormlite</artifactId>
        <version>${android.robospice.ormlite}</version>
        <exclusions>
            <exclusion>
                <groupId>com.google.android</groupId>
                <artifactId>support-v4</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.tojc.ormlite.android</groupId>
        <artifactId>ormlite-content-provider-library</artifactId>
        <version>${android.tojc.ormlite}</version>
    </dependency>

    <dependency>
        <groupId>com.tojc.ormlite.android</groupId>
        <artifactId>ormlite-content-provider-compiler</artifactId>
        <version>${android.tojc.ormlite}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>${android.joda.time}</version>
        <type>jar</type>
    </dependency>

    <!--LOCAL MAVEN DEPENDENCIES-->
    <dependency>
        <groupId>com.google.android.gms</groupId>
        <artifactId>google-play-services</artifactId>
        <version>8</version>
        <type>apklib</type>
    </dependency>

    <dependency>
        <groupId>com.jeremyfeinstein.slidingmenu</groupId>
        <artifactId>slidingmenu</artifactId>
        <version>1.3-SNAPSHOT</version>
        <type>apklib</type>
        <exclusions>
            <exclusion>
                <groupId>com.google.android</groupId>
                <artifactId>support-v4</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.caldroid</groupId>
        <artifactId>library</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>

</dependencies>

<build>
    <sourceDirectory>src</sourceDirectory>

    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <sdk>${android.platform}</sdk>
            </configuration>

        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>

        </plugin>
    </plugins>
</build>

Source code:

        seeCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentTransaction transaction = getFragmentManager().beginTransaction();
                transaction.setCustomAnimations(
                        R.animator.card_flip_right_in, R.animator.card_flip_right_out,
                        R.animator.card_flip_left_in, R.animator.card_flip_left_out);
                Fragment fragment = CardDetailsFragment_.builder().card(card).build();
                transaction.add(R.id.frame_content, fragment).addToBackStack(null).commit();
            }
        });

Here is my error log:

ERROR/AndroidRuntime(2142): FATAL EXCEPTION: main
android.content.res.Resources$NotFoundException: Resource ID #0x10c0006
at android.content.res.Resources.getValue(Resources.java:892)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
at android.content.res.Resources.getAnimation(Resources.java:755)
at android.view.animation.AnimationUtils.loadInterpolator(AnimationUtils.java:254)
at com.nineoldandroids.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:338)
at com.nineoldandroids.animation.AnimatorInflater.loadObjectAnimator(AnimatorInflater.java:192)
at com.nineoldandroids.animation.AnimatorInflater.createAnimatorFromXml(AnimatorInflater.java:145)
at com.nineoldandroids.animation.AnimatorInflater.createAnimatorFromXml(AnimatorInflater.java:157)
at com.nineoldandroids.animation.AnimatorInflater.createAnimatorFromXml(AnimatorInflater.java:121)
at com.nineoldandroids.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:100)
at android.support.v4.app.FragmentManagerImpl.loadAnimator(FragmentManager.java:739)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:898)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1068)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1436)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3709)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
tomkoptel commented 11 years ago

Ok, I found the source of issue :) The problem was in the way I was describing animation in xml.

It was:

    <objectAnimator
        android:valueFrom="-180"
        android:valueTo="0"
        android:propertyName="rotationY"
        android:interpolator="@android:interpolator/accelerate_decelerate"
        android:duration="@integer/card_flip_time_full" />

It should be:

    <objectAnimator
        android:valueFrom="-180"
        android:valueTo="0"
        android:propertyName="rotationY"
        android:interpolator="@interpolator/accelerate_decelerate"
        android:duration="@integer/card_flip_time_full" />

The actual reason was iterpolator which seems to be undefined in older SDK and required the manual setup in res/interpolator/accelerate_decelerate.xml path.