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 4607626
In Process

The Archive Base Latest Questions

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

I followed Android’s Hello, Testing tutorial verbatim, yet when I run it I receive

  • 0

I followed Android’s Hello, Testing tutorial verbatim, yet when I run it I receive an error with the following Failure Trace:

java.lang.NullPointerException
at com.example.helloandroid.test.HelloAndroidTest.testText(HelloAndroidTest.java:72)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

The exception occurs in testText()’s single statement:

  public void testText() {
    assertEquals(resourceString,(String)mView.getText());
  }  

I don’t understand why I am receiving this null pointer exception since both resourceString and mView are initialized in onCreate():

  @Override
  protected void setUp() throws Exception {
      super.setUp();
      mActivity = this.getActivity();
      mView = (TextView) mActivity.findViewById(com.example.helloandroid.R.id.textview);
      resourceString = mActivity.getString(com.example.helloandroid.R.string.hello);
  }

What could explain this in such a simple app?

  • 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-22T00:43:47+00:00Added an answer on May 22, 2026 at 12:43 am

    Answering my own question: The Hello, Testing tutorial is made for the XML version of “Hello, Android”, not for the second, dynamically constructed version.

    I fixed the problem by modifying HelloAndroid‘s onCreate():

      if (false) { // don't use main.xml layout
        TextView tv = new TextView(this);
        tv.setText("Hello, Android");
        setContentView(tv);
      }
      else
        setContentView(R.layout.main);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Android, I've followed the hello world tutorial through and have a
I've followed the tutorial here: http://developer.android.com/resources/tutorials/views/hello-gridview.html I'm wondering how I get place text over
i had followed exactly same procedure on google's tutorial: http://developer.android.com/guide/tutorials/views/hello-mapview.html ...while i got force
I followed the instructions in the Android WebView tutorial (at http://developer.android.com/resources/tutorials/views/hello-webview.html ). When I
i am trying to run google map tutorial using following link http://mobiforge.com/developing/story/using-google-maps-android followed all
I followed a tutorial online on how to receive push notifications on Android. Got
I followed the tutorial at: http://mobile.tutsplus.com/tutorials/android/android-listview/ and was able to successfully run the application.
I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I followed Google's Map View tutorial from this link http://developer.android.com/resources/tutorials/views/hello-mapview.html I've done the first
I have followed the android gallery tutorial to build a simple gallery which is

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.