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

  • SEARCH
  • Home
  • 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 6327019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:12:12+00:00 2026-05-24T17:12:12+00:00

I have a very weird problem with my Android application. Every time I add

  • 0

I have a very weird problem with my Android application. Every time I add a string-array to my strings.xml (or any other file in res/values/), my program crashes on start up. I know, with absolute certainty, that this is what is crashing it (since whenever I remove it, it works fine). Anyway, here is the XML code that causes the crash:

<string-array name="main_list">
        <item>Collections</item>
        <item>Requests</item>
        <item>Forums</item>
</string-array>

Is there something wrong with the formatting of it at all? It is inside the “resources” tags and everything. Here is the full XML file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Activity Names -->
    <string name="app_name">MyFavs</string>
    <!-- Login Vars -->
    <string name="username_login_field">Username</string>
    <string name="password_login_field">Password</string>
    <string name="login_btn">Login!</string>
    <string name="remember_login_tag">Save Login Info</string>
    <string name="no_username_password">You must supply a username and password</string>
    <string name="sign_in_cancelled">Sign-in cancelled</string>
    <string name="sign_in_progress">Signing in...</string>
    <string name="invalid_username_password_alert_title">Error</string>
    <string name="invalid_username_password_alert_btn">Ok</string>
    <string name="menu_forgotten_password">Forgot Password?</string>
    <!-- ForgotPasswd Vars -->
    <string name="forgotten_pass_field">Email</string>
    <string name="forgotten_pass_btn">Recover Account</string>
    <string name="forgot_passwd_progress">Recovering account...</string>
    <string name="invalid_forgot_passwd_title">Recover Account</string>
    <string name="invalid_forgot_passwd_btn">Ok</string>
    <string name="no_email">You must supply a valid email</string>
    <string name="recover_cancelled">Recover cancelled</string>
    <string name="menu_home">Home</string>
    <string-array name="main_list">
        <item>Collections</item>
        <item>Requests</item>
        <item>Forums</item>
    </string-array>
</resources>

Again, removing the “string-array” section at the bottom makes the program work, but adding it causes a crash.

Here is the logcat crash log (although it doesn’t help much):

W/dalvikvm(  849): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime(  849): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(  849): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.myfavs.droid/org.myfavs.droid.login}: java.lang.NullPointerException
E/AndroidRuntime(  849):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
E/AndroidRuntime(  849):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime(  849):        at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime(  849):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime(  849):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  849):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  849):        at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(  849):        at java.lang.reflect.Method.invokeNative(NativeMethod)
E/AndroidRuntime(  849):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  849):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(  849):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(  849):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  849): Caused by: java.lang.NullPointerException
E/AndroidRuntime(  849):        at org.myfavs.droid.login.onCreate(login.java:32)
E/AndroidRuntime(  849):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(  849):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
E/AndroidRuntime(  849):        ... 11 more
I/Process (   51): Sending signal. PID: 849 SIG: 3

If anyone has any ideas, please share them. I have been working on this for quite a long time, and I’m sure it is a stupid mistake but I just need another pair of eyes. I would be willing to try any possible solution.

EDIT:

I removed every reference to the string-array resource and simply including the resource causes the crash. I don’t reference it anywhere, so its not that that is causing the problem.

As requested, here is my onCreate for “login”, although I haven’t touched that code in a long time and it has always worked:

public void onCreate(Bundle savedInstanceState)
    {
    Log.d("Login","onCreate called");
        super.onCreate(savedInstanceState);
    Interactor.create(this);
        setContentView(R.layout.login);
    ((EditText)findViewById(R.id.username)).setText(Interactor.getDB().getSetting("username"));
        EditText pwd = (EditText)findViewById(R.id.password);
    pwd.setText(Interactor.getDB().getSetting("password"));
    if (Interactor.getDB().getSetting("save_login").equals("yes"))
        ((CheckBox)findViewById(R.id.remember_login)).setChecked(true);
        // Treat "Send" soft-button on keyboard as a button click
        pwd.setOnEditorActionListener(new android.widget.TextView.OnEditorActionListener()
                {
                    public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
                    {
                        if (actionId == EditorInfo.IME_ACTION_SEND)
                            ((Button)findViewById(R.id.login_btn)).performClick();
                        return true;
                    }
                });
    }

The exception is being thrown just by including the resource inside res/values even without ever referencing it. That’s why its so weird to me…

EDIT of the EDIT:

Jon Skeet might be on to something. While including the string-array resource, and commenting out line 32 of login’s onCreate (as I said what line that is in the comments above), the application works again. So adding a string-array breaks that line somehow? Any help in why adding the string-array resource would break that, but it works 100% without adding the resource?

  • 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-24T17:12:12+00:00Added an answer on May 24, 2026 at 5:12 pm

    Surely there is no problem with your string array.Problem is in the code where you are accessing the string

    try like this

    Resources res = getResources();
    String[] list = res.getStringArray(R.array.main_list);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very weird problem, when storing my session in Memcached. From time
I have a very weird problem. I have a VB.NET 2.0 application that takes
I have a very weird problem. Have an application using Hibernate and spring.I have
I have a very weird problem: sometimes when I call nHibernate update to an
I have a very weird problem.. I really do hope someone has an answer
I have a very weird problem in Firefox ( version 3.5.2), and I am
I have a very weird problem with PROLOG. I have used it before, but
I have seen some very weird for loops when reading other people's code. I
I'm having a very weird problem with a vector in my application. Details... I
I have a very weird problem.I am in an university and we are supposed

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.