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.

java.lang.NullPointerException

See original GitHub issue

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

java.lang.NullPointerException: Attempt to invoke virtual method ‘android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)’ on a null object reference (ReactTextInputShadowNode.java:77)

React Native version:

Run react-native info in your terminal and copy the results here.

System: OS: macOS 11.1 CPU: (8) x64 Intel® Core™ i5-8279U CPU @ 2.40GHz Memory: 19.66 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 10.15.3 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 23, 25, 26, 27, 28, 29 Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.2 System Images: android-22 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-28 | Android TV Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom IDEs: Android Studio: 4.0 AI-193.6911.18.40.6626763 Xcode: 12.4/12D4e - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: react-native-cli: 2.0.1

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. This was happened randomly. We have tried to reproduce it but can’t find the solution.
  2. We got this crash via Instabug
  3. Please find the attachment for more info Crash#207.txt

Expected Results

Describe what you expected to happen.

Snack, code example, screenshot, or link to a repository:

Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
GaelCOcommented, Jun 9, 2022

It looks like the #17530 issue. This issue was was wrongly closed, because the crash still happens despite the supposed fix and the use of the latest stable version of RN (0.68.2). I write a comment here, because I search an open related issue, before create a new one

1reaction
amangautam72commented, Dec 13, 2022

I am also facing this issue on react-native 0.68.0 in production. React Native : 0.68 Android: 11, Phone : Realme Narzo 50i.

Steps to Reproduce Render textinputs like this in a view vertically.

`import { View, Text, TextInput, FlatList } from ‘react-native’ import React, { useEffect, useState } from ‘react’

export default function Test() { const [startKey, setStartKey] = useState(0);

useEffect(() => {
    const interval = setInterval(() => setStartKey(startKey + 100), 3000);
    return () => clearInterval(interval);
}, [startKey]);

const textInputs = [];
for (let i = 0; i < 100; i++) {
    const key = (startKey + i).toString();
    console.log('Adding a TextInput with key ' + key);
    textInputs.push(
        <TextInput
            style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
            key={key}
            autoFocus
        />,
    );
}
return (
    <View>{textInputs}</View>
)

}`

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference at android.graphics.drawable.DrawableContainer$DrawableContainerState.createAllFutures(DrawableContainer.java:880) at android.graphics.drawable.DrawableContainer$DrawableContainerState.getOpacity(DrawableContainer.java:1163) at android.graphics.drawable.DrawableContainer.getOpacity(DrawableContainer.java:434) at android.graphics.drawable.InsetDrawable.getOpacity(InsetDrawable.java:259) at android.view.View.computeOpaqueFlags(View.java:18906) at android.view.View.setBackgroundDrawable(View.java:24069) at androidx.appcompat.widget.AppCompatEditText.setBackgroundDrawable(AppCompatEditText.java) at android.view.View.setBackground(View.java:23962) at android.view.View.<init>(View.java:6111) at android.widget.TextView.<init>(TextView.java:1020) at android.widget.EditText.<init>(EditText.java:87) at android.widget.EditText.<init>(EditText.java:83) at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:4) at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:2) at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:1) at com.facebook.react.views.textinput.ReactEditText.<init>(ReactEditText.java) at com.facebook.react.views.textinput.ReactTextInputManager.createViewInstance(ReactTextInputManager.java:2) at com.facebook.react.views.textinput.ReactTextInputManager.createViewInstance(ReactTextInputManager.java) at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java) at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java) at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:40) at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:23) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:58) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:23) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:46) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1159) at android.view.Choreographer.doCallbacks(Choreographer.java:983) at android.view.Choreographer.doFrame(Choreographer.java:904) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1146) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:263) at android.app.ActivityThread.main(ActivityThread.java:8292) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - What is a NullPointerException, and how do I fix it?
NullPointerException s are exceptions that occur when you try to use a reference that points to no location in memory ...
Read more >
NullPointerException (Java Platform SE 8 ) - Oracle Help Center
Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of...
Read more >
How to Fix and Avoid NullPointerException in Java - Rollbar
The java.lang.NullPointerException is a runtime exception in Java that occurs when a variable is accessed which is not pointing to any ...
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
This is one of the most common occurrences of java.lang.NullPointerException because it's the caller who is passing the null argument. The below ...
Read more >
How to resolve the java.lang.NullPointerException - Educative.io
In Java, the java.lang.NullPointerException is thrown when a reference variable is accessed (or de-referenced) and is not pointing to any object.
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