Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7031513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:48:46+00:00 2026-05-28T00:48:46+00:00

I have been writing this Android application for the past few days and everything

  • 0

I have been writing this Android application for the past few days and everything has been working smoothly, until today. In my app I was trying to implement a tabbed view for my application, but as soon as I try to run it my application installs and force closes immediately upon opening. I have been sitting at this for an entire day and cannot for the life of me figure out what the issue is. Hopefully someone can help me out.

E/AndroidRuntime(5469): FATAL EXCEPTION: main
E/AndroidRuntime(5469): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo
{com.stullich.tim.lolbufftimer/com.stullich.tim.lolbufftimer.LoLBuffTimerMain}: java.lang.NullPointerException
E/AndroidRuntime(5469):at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:1573) 
E/AndroidRuntime(5469): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
E/AndroidRuntime(5469): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime(5469): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
E/AndroidRuntime(5469): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(5469): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(5469): at android.app.ActivityThread.main(ActivityThread.java:3691)
E/AndroidRuntime(5469): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(5469): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(5469): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:907)
E/AndroidRuntime(5469): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
E/AndroidRuntime(5469): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(5469): Caused by: java.lang.NullPointerException
E/AndroidRuntime(5469): at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
E/AndroidRuntime(5469): at com.stullich.tim.lolbufftimer.LoLBuffTimerMain.<init>(LoLBuffTimerMain.java:14)
E/AndroidRuntime(5469): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(5469): at java.lang.Class.newInstance(Class.java:1409)
E/AndroidRuntime(5469): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(5469): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
E/AndroidRuntime(5469):     ... 11 more

Here is the code for the main activity:

public class LoLBuffTimerMain extends TabActivity{

Resources res = getResources(); 
TabHost tabHost = getTabHost(); 
TabHost.TabSpec spec;  
Intent intent;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    intent = new Intent().setClass(this, YourBuffs.class);

    spec = tabHost.newTabSpec("yourbuffs").setIndicator("Your Buffs", 
                        res.getDrawable(R.drawable.tab_view_you))
                  .setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, EnemyBuffs.class);
    spec = tabHost.newTabSpec("enemybuffs").setIndicator("Enemy Buffs", 
                        res.getDrawable(R.drawable.tab_view_enemy))
                  .setContent(intent);
    tabHost.addTab(spec);
    }
}

and the XML:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent">
    <TabWidget android:id="@android:id/tabs"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent" />
    <FrameLayout android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">        
    </FrameLayout>
</TabHost>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:48:47+00:00Added an answer on May 28, 2026 at 12:48 am

    The stack trace points to this line as the source of the exception:

    Resources res = getResources(); 
    

    The inherited getResources() method is throwing an exception. That’s because you can’t call getResources() until later, after the activity is constructed and initialized. Move those member variable initializations into onCreate() and you should be good to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an android application in OpenCV, and have been spending a few hours
I am writing my first Android application, and I have been struggling with this
I have been working with eclipse and android for a few months now and
I have been fiddling a bit with android the last few days. I have
I've been experimenting with the Android SDK over the past few days, in readiness
I have been writing a SOAP client application in C++ on Ubuntu using OpenSSL
I have been writing an application using ASP.Net MVC4, where the majority of the
I'm writing my first Android application and I have one activity that I'd like
I have an application I am writing for Android that basically does a screen
I have been writing a chat app for android. I am implementing Google talk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.