- Understanding java.lang.reflect.InvocationTargetException and why it occurs
- Reason for java.lang.reflect.InvocationTargetException
- Handle InvocationTargetException
- [Solved] Render Problem with java.lang.reflect.InvocationTargetException (Android Studio)
- Saved searches
- Use saved searches to filter your results more quickly
- Error in Android caused by: java.lang.reflect.InvocationTargetException #16531
- Error in Android caused by: java.lang.reflect.InvocationTargetException #16531
- Comments
- Is this a bug report?
- Have you read the Contributing Guidelines?
- Environment
- Steps to Reproduce
Understanding java.lang.reflect.InvocationTargetException and why it occurs
In this post, we will see about java.lang.reflect.InvocationTargetException .
You might get java.lang.reflect.InvocationTargetException while working with reflection in java.
Reason for java.lang.reflect.InvocationTargetException
Reflection layer throws this exception when calling method or constructor throws any exception. java.lang.reflect.InvocationTargetException wraps underlying exception thrown by actual method or constructor call.
Let’s see this with the help of example:
Create a simple class named StringUtils.java . It will have method getLengthOfString() which does not have null handling, so when we pass null to this method, it will throw java.lang.NullPointerException.
Create anther class to call getLengthOfString using reflection.
> catch ( NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e )
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.arpit.java2blog.ReflectionMain.main(ReflectionMain.java:16)
Caused by: java.lang.NullPointerException
at org.arpit.java2blog.StringUtils.getLengthOfString(StringUtils.java:7)
… 5 more
As you can see, we are getting java.lang.reflect.InvocationTargetException exception because of underlying NullPointerException.
Reflection layer wraps java.lang.reflect.InvocationTargetException around actual Exception to demostrate that this exception was raised during reflection API call.
Handle InvocationTargetException
As underlying exception is actual cause of InvocationTargetException, we can use Throwable’s getCause() method to get actual underlyting exception and use it to log or rethrow the exception.
[Solved] Render Problem with java.lang.reflect.InvocationTargetException (Android Studio)
tsk Asks: Render Problem with java.lang.reflect.InvocationTargetException (Android Studio)
I created a new app with no activity and replaced files generated from figma to android studio in standard directory format. The export plugin gave me java, res and manifest file which I pasted into my app src/main directory. Now I am getting render problem for the ‘xml’ file after I rebuild the project.
Following is the error stack for the render problem:
java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at android.view.BridgeInflater.lambda$createViewFromCustomInflater$0(BridgeInflater.java:259) at android.view.BridgeInflater.createViewFromCustomInflater(BridgeInflater.java:285) at android.view.BridgeInflater.onCreateView(BridgeInflater.java:122) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:934) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:954) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1008) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:309) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.inflate(LayoutInflater.java:686) at android.view.LayoutInflater.inflate(LayoutInflater.java:505) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873) at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.lang.NullPointerException at android.graphics.fonts.Font_Builder_Delegate.createBuffer(Font_Builder_Delegate.java:52) at android.graphics.fonts.Font$Builder.createBuffer(Font.java:264) at android.graphics.fonts.Font$Builder.(Font.java:200) at android.graphics.Typeface$Builder.(Typeface.java:517) at android.graphics.Typeface_Delegate.createFromDisk(Typeface_Delegate.java:91) at com.android.layoutlib.bridge.impl.ResourceHelper.getFont(ResourceHelper.java:488) at com.android.layoutlib.bridge.impl.ResourceHelper.getFont(ResourceHelper.java:500) at android.content.res.BridgeTypedArray.getFont(BridgeTypedArray.java:723) at android.widget.TextView.readTextAppearance(TextView.java:4087) at android.widget.TextView.(TextView.java:1125) at android.widget.TextView.(TextView.java:1026) at androidx.appcompat.widget.AppCompatTextView.(AppCompatTextView.java:113) at androidx.appcompat.widget.AppCompatTextView.(AppCompatTextView.java:108) at androidx.appcompat.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:228) at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:148) . 43 more
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in Android caused by: java.lang.reflect.InvocationTargetException #16531
Error in Android caused by: java.lang.reflect.InvocationTargetException #16531
Comments
I have an application that is giving many errors on many Android devices. In IOS there are no errors.
The problem is that we are not able to reproduce them. We have tested dozens of physical android and there are no errors.
But locks on the Google Play Console are alarming.
Is there any way to know which file is giving the error of my .js?
Is this a bug report?
Have you read the Contributing Guidelines?
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.6.0
Yarn: 1.2.0
npm: 5.3.0
Watchman: 4.7.0
Xcode: Xcode 8.3.3 Build version 8E3004b
Android Studio: 2.3 AI-162.4069837
Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: 0.48.1 => 0.48.1
«name»: «xxxxx»,
«version»: «0.0.1»,
«private»: true,
«scripts»: «start»: «node node_modules/react-native/local-cli/cli.js start»,
«test»: «jest»
>,
«dependencies»: «react»: «16.0.0-alpha.12»,
«react-native»: «0.48.1»,
«react-native-app-intro»: «^1.1.5»,
«react-native-dates»: «^2.0.4»,
«react-native-drawer»: «^2.5.0»,
«react-native-elements»: «^0.17.0»,
«react-native-google-api-availability-bridge»: «^1.3.0»,
«react-native-google-places-autocomplete»: «^1.3.6»,
«react-native-image-picker»: «^0.26.7»,
«react-native-keyboard-aware-scroll-view»: «^0.3.0»,
«react-native-loader»: «^1.1.0»,
«react-native-maps»: «^0.17.0»,
«react-native-modal-picker»: «^0.0.16»,
«react-native-permissions»: «^1.0.1»,
«react-native-phone-call»: «^1.0.4»,
«react-native-pie»: «^0.4.0»,
«react-native-rating»: «^2.0.4»,
«react-native-splash-screen»: «^3.0.1»,
«react-native-vector-icons»: «^4.4.2»,
«react-native-zoom-image»: «^0.1.1»,
«react-timer-mixin»: «^0.13.3»
>,
«devDependencies»: «babel-jest»: «21.2.0»,
«babel-preset-react-native»: «4.0.0»,
«jest»: «21.2.1»,
«react-test-renderer»: «16.0.0-alpha.12»
>,
«jest»: «preset»: «react-native»
>
>
Steps to Reproduce
Open the app and load the first js, and the app crash.
com.facebook.react.bridge.JSApplicationIllegalArgumentException: at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp (ViewManagersPropertyCache.java:95) at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty (ViewManagerPropertyUpdater.java:129) at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps (ViewManagerPropertyUpdater.java:48) at com.facebook.react.uimanager.ViewManager.updateProperties (ViewManager.java:36) at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties (NativeViewHierarchyManager.java:125) at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute (UIViewOperationQueue.java:93) at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:776) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:855) at com.facebook.react.uimanager.UIViewOperationQueue.access$1600 (UIViewOperationQueue.java:46) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded (UIViewOperationQueue.java:900) 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:894) at android.view.Choreographer.doCallbacks (Choreographer.java:698) at android.view.Choreographer.doFrame (Choreographer.java:630) at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:882) at android.os.Handler.handleCallback (Handler.java:815) at android.os.Handler.dispatchMessage (Handler.java:104) at android.os.Looper.loop (Looper.java:207) at android.app.ActivityThread.main (ActivityThread.java:5791) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:901) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:762) Caused by: java.lang.reflect.InvocationTargetException: at java.lang.reflect.Method.invoke (Native Method) at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp (ViewManagersPropertyCache.java:83)
The text was updated successfully, but these errors were encountered: