Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

App not running at all and no error code Adding the OnClick Method 2:57 with Ben Deitch

ok, so I am doing this section of the course and my app won't run. not on an emulator or on my Xperia x. and I see no errors. I've tried updating that didn't work. But what bothers me is the fact that it worked perfectly in the previous sections. What am I doing wrong? Should i post some code here? I'm very new to this. i hope you can help me .

7 Answers

What operating system are you using ??

Windows 10

does that make a difference?

If you are using Linux is a big difference ?

um but it is using android studio?

Did try to run other app ?

um no. dont have any other app. and like is said the app worked perfectly before this section. im still new to this

Sorry I did a search on eclipse.

lol, anyway you can look at my code?

No. I don't see any code

um i think you misunderstood my question. i meant can you please look at my code?

id appreciate it if you could help me?

E/AndroidRuntime: FATAL EXCEPTION: main Process: za.co.nissiacademy.funfacts, PID: 12752 java.lang.RuntimeException: Unable to start activity ComponentInfo{za.co.nissiacademy.funfacts/za.co.nissiacademy.funfacts.FunFactActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) at android.app.ActivityThread.access$900(ActivityThread.java:154) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:234) at android.app.ActivityThread.main(ActivityThread.java:5526) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at za.co.nissiacademy.funfacts.FunFactActivity.onCreate(FunFactActivity.java:32) at android.app.Activity.performCreate(Activity.java:6285) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)  at android.app.ActivityThread.access$900(ActivityThread.java:154)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:234)  at android.app.ActivityThread.main(ActivityThread.java:5526)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Zoé,

I'm sorry, I don't use Windows at all, so I'm not sure I can be much help. You said that it worked in the previous sections, so it's very possible that you introduced a minor syntax issue in the current section that is preventing from running. You will have to have a look at all you code (especially the lines added since the last section). It could be as simple as a missing semi-colon or comma. Remember to also check you XML files.

If you can't figure it out and depending on which course you are referring to, you should be able to download the course files that would be complete up to the point where you are in the course. Not all courses provide this, however. But most courses to provide starter files for each section at least.

Hope you get this all sorted out soon. :)

Keep Coding! :dizzy: