0

The activity where lies the problem in app works fine for a moment, but at one moment (after clicking on same list that didn't cause the app to crash at the begining) it crashes ..and i get this in my logcat ..can't understand why? I've searched on internet for similar cases but with no luck ..( i did found similar exception but not for same cause) ..if you want my java classes..i'll post them .. PS: this is the only code red after the begininng of crash

   --------- beginning of crash
    09-03 21:01:44.672 7515-7580/ma.ac.iav.menunaviagtion E/AndroidRuntime: FATAL EXCEPTION: Thread-5
        Process: ma.ac.iav.menunaviagtion, PID: 7515
        java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
            at com.android.tools.profiler.support.profilers.EventProfiler$InputConnectionHandler.run(EventProfiler.java:285)
            at java.lang.Thread.run(Thread.java:764)
Zouhair
  • 145
  • 1
  • 2
  • 13
  • maybe this helps you to understand your problem: https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it – leonardkraemer Sep 03 '18 at 21:13
  • it's not my first null ponter exception ..trying to create the app i have solved many encountered null pointer by myslef without posting them here..but this one is hard because there is no obvious cause in code from logcat ..can you show me what does the logcat means ..thanks – Zouhair Sep 03 '18 at 21:16
  • can you reproduce the problem, when you are doing a release build and the device is not attached to the pc? looks like an error with the profiler. also make sure to run the latest version of android studio. – leonardkraemer Sep 03 '18 at 21:18
  • i tried insalling the app in a phone and the app works fine without crashing ever ..so you think the proble is related to the emulator only? – Zouhair Sep 03 '18 at 21:22
  • 1
    I think the problem is caused by the [profiler](https://developer.android.com/studio/profile/android-profiler). try disabling the profiling and see if it works – leonardkraemer Sep 03 '18 at 21:24
  • Please write your solution in a post so i can accept it ..you were right..the app in the emulator works great now ..do youu know why the profiler cause this problem? – Zouhair Sep 03 '18 at 21:32
  • and do you have any idea why people put thmubs down! like i'm posting a stupid or well known problem! – Zouhair Sep 03 '18 at 21:32
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/179337/discussion-between-leonardkraemer-and-zouhair). – leonardkraemer Sep 03 '18 at 21:34

1 Answers1

1

The stacktrace suggests that the problem is caused by the Profiler.

Disabling the profiling and it should work. You can disable profiling by clicking end session in the profiler tab or by disconnecting the usb cable (when you have a real device).

This error will likely be fixed in future versions ov Android Studio, so make sure to update you IDE.

leonardkraemer
  • 6,573
  • 1
  • 31
  • 54