Closed wxjer closed 2 years ago
Facing Same Issue.
Same here RN@0.49.0
com.facebook.react.views.textinput.ReactEditText.onTouchEvent
ReactEditText.java - line 163
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
Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference
1
android.graphics.drawable.DrawableContainer$DrawableContainerState.getChild DrawableContainer.java:884
2
android.graphics.drawable.DrawableContainer.selectDrawable DrawableContainer.java:466
3
android.graphics.drawable.StateListDrawable.onStateChange StateListDrawable.java:104
4
android.graphics.drawable.Drawable.setState Drawable.java:736
5
android.graphics.drawable.DrawableWrapper.onStateChange DrawableWrapper.java:331
6
android.graphics.drawable.Drawable.setState Drawable.java:736
7
android.view.View.drawableStateChanged View.java:19223
8
android.widget.TextView.drawableStateChanged TextView.java:4673
9
android.view.View.refreshDrawableState View.java:19292
10
android.view.View.setPressed View.java:9135
11
android.view.View.setPressed View.java:9113
12
android.view.View.onTouchEvent View.java:12357
13
android.widget.TextView.onTouchEvent TextView.java:10095
14
com.facebook.react.views.textinput.ReactEditText.onTouchEvent ReactEditText.java:163
Same Issue
Same issue. Same logtrace
Same here on RN 44.0
+1 anotha' one
Guys restarting the packager and clearing cache worked for me!
Same issue for me. I am using RN 0.51.0 and react-native-material-textfield 0.12.0.
I am facing this issues as well. The strange thing is that it is very hard to track the error as the stack trace does not contain any useful information. I even do not know what where the error could be. Will update here If i find the solution
Same error happening on RN 0.52.0.
Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?
I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.
Same issue on 0.53.3
Same issue
@react-native-bot Need to reopen issue
facing the same issue with Android 8
Same here. React native 0.53.3, SM-T550, API Level 25 (Android 7.0)
this issue just popped up with me, React native 0.53.3 - Android 8.1.
React native 0.53.3, android 8, same issue
Same issue, react-native 0.53.0 and android 8. It strange cause this error seems to appears randomly. I can't find any exact steps to reproduce it.
Have a production app running RN 0.54.2 and this seems to affect a few users running Android 8.0.0 on app startup.
Why is this issue closed? Some of us are facing this issue in production environment, so "restarting the packager" is not an acceptable solution.
This issue needs to be reopened since it affects current version.
I am also facing stack traces that might be related:
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:875)
at android.graphics.drawable.DrawableContainer$DrawableContainerState.getOpacity(DrawableContainer.java:1158)
at android.graphics.drawable.DrawableContainer.getOpacity(DrawableContainer.java:433)
at android.graphics.drawable.InsetDrawable.getOpacity(InsetDrawable.java:258)
at android.view.View.computeOpaqueFlags(View.java:16791)
at android.view.View.setBackgroundDrawable(View.java:21710)
at android.view.View.setBackground(View.java:21603)
at android.view.View.<init>(View.java:5547)
at android.widget.TextView.<init>(TextView.java:1135)
at android.widget.EditText.<init>(EditText.java:107)
at android.widget.EditText.<init>(EditText.java:103)
at android.widget.EditText.<init>(EditText.java:99)
at android.widget.EditText.<init>(EditText.java:95)
at com.facebook.react.views.textinput.ReactEditText.<init>(ReactEditText.java:92)
at com.facebook.react.views.textinput.ReactTextInputManager.createViewInstance(ReactTextInputManager.java:94)
at com.facebook.react.views.textinput.ReactTextInputManager.createViewInstance(ReactTextInputManager.java:65)
at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:46)
at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:218)
at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:150)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:923)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:895)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:655)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.DrawableContainer$DrawableContainerState$ConstantStateFuture.get(android.graphics.drawable.DrawableContainer$DrawableContainerState)' on a null object reference
at android.graphics.drawable.DrawableContainer$DrawableContainerState.getChild(DrawableContainer.java:823)
at android.graphics.drawable.DrawableContainer.selectDrawable(DrawableContainer.java:452)
at android.graphics.drawable.StateListDrawable.onStateChange(StateListDrawable.java:104)
at android.graphics.drawable.Drawable.setState(Drawable.java:680)
at android.graphics.drawable.DrawableWrapper.onStateChange(DrawableWrapper.java:279)
at android.graphics.drawable.Drawable.setState(Drawable.java:680)
at android.graphics.drawable.LayerDrawable.onStateChange(LayerDrawable.java:1381)
at android.graphics.drawable.Drawable.setState(Drawable.java:680)
at android.view.View.drawableStateChanged(View.java:17003)
at android.widget.TextView.drawableStateChanged(TextView.java:3984)
at android.view.View.refreshDrawableState(View.java:17067)
at android.view.View.setPressed(View.java:7914)
at android.view.View.setPressed(View.java:7892)
at android.view.View.access$2900(View.java:708)
at android.view.View$CheckForTap.run(View.java:21187)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
@grabbou can we re-open this issue?
Same issue here android 8.0 api 26
Same on 0.54.2.
I've narrowed it down to a <TextInput>
being rendered within in a FlatList. When I replace this with a <Text>
, the issue disappears.
Please reproduce with the latest version available now and I will reopen this.
Same here @radko93
Android 8.1 API 27
"dependencies": { "react": "16.3.1", "react-native": "0.55.1", "react-native-linear-gradient": "^2.4.0", "react-native-vector-icons": "^4.6.0", "react-navigation": "^1.5.11" },
Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference createAllFutures DrawableContainer.java:875 getOpacity DrawableContainer.java:1158 getOpacity DrawableContainer.java:433 getOpacity InsetDrawable.java:258 computeOpaqueFlags View.java:15698 setBackgroundDrawable View.java:20502 setBackground View.java:20395
Same issue
package.json "dependencies": { "react": "16.3.1", "react-native": "0.55.2", },
build.gradle compileSdkVersion 26 buildToolsVersion "26.0.2" minSdkVersion 16
Same issue.
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.getChild(DrawableContainer.java:888)
at android.graphics.drawable.DrawableContainer.selectDrawable(DrawableContainer.java:466)
at android.graphics.drawable.StateListDrawable.onStateChange(StateListDrawable.java:104)
at android.graphics.drawable.Drawable.setState(Drawable.java:735)
at android.graphics.drawable.DrawableWrapper.onStateChange(DrawableWrapper.java:331)
at android.graphics.drawable.Drawable.setState(Drawable.java:735)
at android.view.View.drawableStateChanged(View.java:18038)
at android.widget.TextView.drawableStateChanged(TextView.java:4108)
at android.view.View.refreshDrawableState(View.java:18107)
at android.view.View.setPressed(View.java:8536)
at android.view.View.setPressed(View.java:8514)
at android.view.View.onTouchEvent(View.java:11262)
at android.widget.TextView.onTouchEvent(TextView.java:8489)
at com.facebook.react.views.textinput.ReactEditText.onTouchEvent(ReactEditText.java:162)
at android.view.View.dispatchTouchEvent(View.java:10054)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2336)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:432)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1841)
at android.app.Activity.dispatchTouchEvent(Activity.java:3233)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:394)
at android.view.View.dispatchPointerEvent(View.java:10286)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4514)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4370)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3883)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3953)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3911)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4053)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3919)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4110)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3883)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3953)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3911)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3919)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3883)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6359)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6333)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6288)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6469)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:193)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:6295)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:900)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:790)
Android: 7.1.1 React-Native: 0.48.3
Same issue.
same issue ,in the production environment,my device is HUAWEI(LLD-AL10) 8.0.0 ,I am currently using React Native 0.46.2,thanks
Getting the same issue when using the latest version of react-native (0.55.3). The issue seems to be related to TextInput in a FlatList as mentioned above. Getting the error in android 8.0 and 8.1. Any workarounds to avoid this issue?
I can reproduce this bug by creating a new React Native project with react-native init and changing the App.js to
import React, { Component } from 'react';
import {
StyleSheet,
TextInput,
View
} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
render() {
const inputs = Array.apply(null, Array(256)).map((_, i) => i)
return (
<View>
{inputs.map(i => <TextInput key={i} />)}
</View>
);
}
}
I was running this on a Galaxy S8 with Android 8.0.0 from MacOS 10.13.3.
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.3"
},
I don't know if the error is not directly tied to the number of TextInputs, but this is the only way I could reproduce this bug in a fairly reliable fashion. With 128 inputs I didn't get this error on every restart but after a few reloads it did come up. At 256 bare TextInputs I don't think I have been able to start the application without getting the error. I also noticed that adding elements between the TextInputs seemed to reduce the likelihood of getting this error, so it is likely not directly tied to the number of TextInputs. I tried this in my current application and adding hundreds of TextInputs to the starting screen did also trigger this error, but my other views with similar amounts of TextInputs wrapped in other elements do not seem to always trigger this error as I have some in my application.
I have the same issue. I was running this on a Huawei P10 with Android 8.0.0.
"react": "^16.2.0", "react-native": "^0.55.0",
Screenshot
It seems like the problem is in the TextInputs. This happens on my Huawei P10 (Android 8.0.0). Is there a fix for this already?
Android:7.1.1 "react-native": "0.53.3",
Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?
Thank you for your contributions.
I'm facing the same issue. It's related to the TextInput component. Even a single TextInput being rendered in a screen is causing this error. Are there any workarounds?
react-native: 0.55 react: 16.3.1
I change the ReactEditText constructor “ super“, it looks not happen, but comment out “underlineColorAndroid ” https://github.com/yuanboGeng/react-native/commit/36f7949f9a3e9c1f3b10df43a9f495f9f8712a1f react-native: 0.53.3 react: 16.2.0
This started happening for me after upgrading my emulator to API level 26 from API level 21
I had this error appearing for no reason while developing. I cleaned out my /build folders and ran a run-android
again. The issue disappeared. Really weird. I hope for some of you a clean build will resolve this.
Having this same problem. One small difference - in mine I am nesting TextInputs inside of a VirtualizedList (the parent of FlatList) and I only get the issue when I start scrolling around in that list, even then only getting it intermittently rather than all the time. Similarly to others, this is happening in a production environment, so restarting the packager is not an option.
Based on some digging, appears related to an old issue in Android itself: https://issuetracker.google.com/issues/37068452 If that is the underlying problem, this would be solved by just upgrading the compileSdk and support library versions in the RN project. No idea the LoE on that, though.
Update: trying to force subprojects to use a higher version of the build tools and compileSdk did not solve this problem for my project, as explained in this SO post. Not sure if I just applied those higher versions wrong, if my build setup isn't treating RN as a subproject in that way, or if it was actually not a valid solution for the problem here.
EDIT 2: It appears that ReactEditText isn't even using the support library version of EditText (which would be AppCompatEditText), which explains why upgrading the support library didn't do anything. I'm looking into this - it'll take a couple more updates than just changing the inheritance to get this to work, but it might be the right solution to this problem.
EDIT 3: It was not the solution. I am no longer confident that this issue is the same as the linked AOSP one. I can say that it doesn't appear to matter what kind of ScrollView you put your text in - I was able to reproduce in both VirtualizedList and ScrollView, and many in this thread have done it with a FlatList.
i have this same on production
I also am facing this issue. Running cd android ; ./gradlew clean ; cd .. ; react-native run-android
works for me as @mbret pointed out (thanks!)
Great, but what about apps on production with real clients? :|
Sorry @ahanusek, I am not saying this resolves the issue, I am just saying that in development this worked for me (in hopes that it will also help someone else).
But even for development it's not a solution. Ok, you clean your build, start app again, but if you use inputs "hardly" you still could get this error again.
@ahanusek Yes, I agree with you, and am in no way arguing with you. This isn't a solution, but for me, and for now, it has worked to allow me to continue to develop
Also seeing this, v0.55.4:
Fairly certain I don't have a TextField in a FlatList or VirtualizedList, fwiw. This is happening in our production build.
Is this a bug report?
yes
Have you read the Contributing Guidelines?
yes, I am sorry that I cant offer more information about this exception except for this stack trace because the crash report was collected from google analytics, I have no idea to reappear this exception.
Environment
Environment: OS: macOS Sierra 10.12.6 Node: 8.4.0 Yarn: 0.27.5 npm: 5.4.0 Android Studio: 3.0
Packages: (wanted => installed) react-native: 0.51.0 => 0.51.0 react: 16.0.0-alpha.12 => 16.0.0-alpha.12
Target Platform: Android (7.1.1) mobile:MIX 2 android:7.1.1 java.lang.NullPointerException:
tempt 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.getChild(DrawableContainer.java:888) at android.graphics.drawable.DrawableContainer.selectDrawable(DrawableContainer.java:466) at android.graphics.drawable.StateListDrawable.onStateChange(StateListDrawable.java:104) at android.graphics.drawable.Drawable.setState(Drawable.java:735) at android.graphics.drawable.DrawableWrapper.onStateChange(DrawableWrapper.java:331) at android.graphics.drawable.Drawable.setState(Drawable.java:735) at android.graphics.drawable.LayerDrawable.onStateChange(LayerDrawable.java:1488) at android.graphics.drawable.Drawable.setState(Drawable.java:735) at android.view.View.drawableStateChanged(View.java:18002) at android.widget.TextView.drawableStateChanged(TextView.java:4097) at android.view.View.refreshDrawableState(View.java:18071) at android.view.View.setPressed(View.java:8543) at android.view.View.setPressed(View.java:8521) at android.view.View.onTouchEvent(View.java:11218) at android.widget.TextView.onTouchEvent(TextView.java:8467) at com.facebook.react.views.textinput.ReactEditText.onTouchEvent(ReactEditText.java:150)