Skip to content

Color animations are broken on Android #1770

Closed

Description

@tjvantoll

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes

Tell us about the problem

On Android color animations don’t seem to work.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 1.6.2
  • Cross-platform modules: 1.6.3
  • Runtime(s): 1.6.3 (Android)
  • Plugin(s): None

Please tell us how to recreate the issue in as much detail as possible.

Recreating the problem is pretty simple—just try to animate the backgroundColor of any view.

<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="loaded">
  <StackLayout id="container">
    <Label text="hello world" />
  </StackLayout>
</Page>
exports.loaded = function(args) {
  var page = args.object;
  page.getViewById("label").animate({
    backgroundColor: "red"
  });
};

Here’s the full exception I get:

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.foo/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
Calling js method onCreateView failed

Error: java.lang.NumberFormatException: Invalid int: "null"
    java.lang.Integer.invalidInt(Integer.java:138)
    java.lang.Integer.parseInt(Integer.java:358)
    java.lang.Integer.parseInt(Integer.java:334)
    java.lang.Integer.valueOf(Integer.java:525)
    com.tns.Platform.callJSMethodNative(Native Method)
    com.tns.Platform.dispatchCallJSMethodNative(Platform.java:812)
    com.tns.Platform.callJSMethod(Platform.java:711)
    com.tns.Platform.callJSMethod(Platform.java:690)
    com.tns.Platform.callJSMethod(Platform.java:680)
    com.tns.gen.android.app.Fragment_ftns_modules_ui_frame_frame_l34_c42__.onCreateView(android.app.Fragment.java)
    android.app.Fragment.performCreateView(Fragment.java:2053)
    android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894)
    android.app.FragmentManagerImpl.moveToS

Activity

  1. bradmartin commented on Mar 16, 2016

    @bradmartin
    Contributor

    @tjvantoll - does it work with hex colors or if you use the color module like new color.Color("#3489db").android;? I didn't go digging in the source but wonder if the animation api doesn't have access the the "known colors" by name. Just a guess 👍

  2. tjvantoll commented on Mar 16, 2016

    @tjvantoll
    ContributorAuthor

    Good catch @bradmartin! Using the Color class does work, and that’s actually what the docs show.

    age.getViewById("label").animate({
      backgroundColor: new Color("red")
    });

    So now I’m curious why passing a plain color works on iOS but not on Android. It seems like they should be consistent. Also, we should probably consider adding a nicer error message when the user does pass in bad data. Error: java.lang.NumberFormatException: Invalid int: "null" didn’t really point me in the right direction.

  3. self-assigned this
    on Mar 24, 2016
  4. added this to the milestone on Mar 24, 2016
  5. lock commented on Aug 30, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  6. locked and limited conversation to collaborators on Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions