question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android interpolate color - Attempt to invoke virtual method 'int java.lang.Double.intValue()' on a null object reference

See original GitHub issue

Description

I’m attempting to combine useAnimatedProps and interpolateColor with react-native-linear-gradient, everything works fine on iOS, however on Android I seem to get an exception.

I don’t think this is a react-native-linear-gradient issue to be clear, it looks like setProps sends null values even though the JS thread reports them as not being null;

// JS
11-18 09:46:50.445 12090 12298 I ReactNativeJS: { colors: [ -16763747, -14621774, -14024762 ] }
Native     @ReactProp(name=PROP_COLORS)
11-18 09:46:50.469 12090 12090 I System.out: [null,null,null]

Working version on iOS

Attempt to invoke virtual method 'int java.lang.Double.intValue()' on a null object reference
11-18 09:10:52.905  7892  7892 E unknown:ReactNative: 	at com.facebook.react.bridge.ReadableNativeArray.getInt(ReadableNativeArray.java:97)
11-18 09:10:52.905  7892  7892 E unknown:ReactNative: 	at com.BV.LinearGradient.LinearGradientView.setColors(LinearGradientView.java:51)
11-18 09:10:52.905  7892  7892 E unknown:ReactNative: 	at com.BV.LinearGradient.LinearGradientManager.setColors(LinearGradientManager.java:35)
11-18 09:10:52.905  7892  7892 E unknown:ReactNative: 	... 23 more

Steps To Reproduce

The Repository

The Component

Expected behavior

Animation works.

Actual behavior

App crashes with above exception. It looks like however reanimated v2 sets props on android, it results in sending [null,null,null].

Package versions

 "react-native": "0.63.3",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-reanimated": "^2.0.0-alpha.9",

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
karol-bisztygacommented, Nov 24, 2020

If you have your doubts, you can open a new issue with the question about what bothers you. Here we wanted to find out why the app crashes.

Thanks for cooperation and quick replies, best regards ✌️

0reactions
kyle-ssgcommented, Nov 24, 2020

Ok sure I guess this can be closed, I think I’m still a bit confused as to why I had to run Android prop updates via state / runOnJS (essentially an infinite loop as you say) rather than useAnimatedProps but I guess this could be react-native-linear-gradient side rather than reanimated.

Ok will just do some more figuring out, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attempt to invoke virtual method 'int.java.lang.Integer.intValue ...
writeInteger() method, you're going to have to record whether or not id is null in a separate write. Something like: if (id ==...
Read more >
Canvas - Android Developers
Usage with a hardware accelerated canvas requires an internal copy of color buffer contents every time this method is called. Using a Bitmap...
Read more >
attempt to invoke virtual method react native - You.com
The error clearly mentions that android.database.Cursor android.database.sqlite.SQLiteDatabase.query(java.lang.String, java.lang.String[], java.lang.
Read more >
resource leak in java Code Example - Code Grepper
Resource leak: 'Object' is never closed Type Object = new Type(); Object.doSomething(); Object.close() //This is to ensure that the object is clossed to ......
Read more >
Groovy Language Documentation
Groovy lets you instantiate java.lang.String objects, as well as GStrings ( groovy.lang.GString ) which are also called interpolated strings in other ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found