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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:28:49+00:00 2026-06-01T04:28:49+00:00

im really desperate right now, ive tried everything. Everytime i run my app this

  • 0

im really desperate right now, ive tried everything.

Everytime i run my app this it force closes. It shows this in the logcat.

04-02 21:26:33.079: E/AndroidRuntime(18013): FATAL EXCEPTION: main
04-02 21:26:33.079: E/AndroidRuntime(18013): java.lang.RuntimeException: Unable to            start activity ComponentInfo{com.pxr.tutorial.xmltest/com.pxr.tutorial.xmltest.Main}:    java.lang.NullPointerException
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.os.Looper.loop(Looper.java:137)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.ActivityThread.main(ActivityThread.java:4424)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at java.lang.reflect.Method.invokeNative(Native Method)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at java.lang.reflect.Method.invoke(Method.java:511)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at dalvik.system.NativeStart.main(Native Method)
04-02 21:26:33.079: E/AndroidRuntime(18013): Caused by: java.lang.NullPointerException
04-02 21:26:33.079: E/AndroidRuntime(18013):    at com.pxr.tutorial.xmltest.Main.onCreate(Main.java:41)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.Activity.performCreate(Activity.java:4465)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-02 21:26:33.079: E/AndroidRuntime(18013):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-02 21:26:33.079: E/AndroidRuntime(18013):    ... 11 more

Main.java

public class Main extends ListActivity {
private AdView adView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listplaceholder);

    LinearLayout layout = (LinearLayout)findViewById(R.layout.main);
    adView = new AdView(this, AdSize.BANNER, "here i put my id with the quotes");
    layout.addView(adView);
    AdRequest adRequest = new AdRequest();
    adRequest.setTesting(true);
    adView.loadAd(adRequest);

Manifest:

<activity
            android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

Main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

listplaceholder.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">    

    <ListView
        android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:drawSelectorOnTop="false" />

    <TextView
        android:id="@id/android:empty"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="No data"/>

</LinearLayout>

Yes i imported the libaries and i changed build target. I also changed lib to libs.

Please help me 🙁

  • 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-06-01T04:28:50+00:00Added an answer on June 1, 2026 at 4:28 am

    Since you stated that

    layout.addView(adView);
    

    throws the NullPointerException, it’s most likely that

    findViewById(R.layout.main);
    

    returned null and layout keeps that in the lines below. And that’s actually the case here. You use R.layout.main, which is a layout reference. You need an ID though, hence findViewById() – so in this case it will never work.

    So to get this working, you need two things:

    First, you need to assign an id to a LinearLayout. I guess the intended one is the outer one in listplaceholder.xml, and it has no id yet. Add an android:id xml attribute, it should look like this in the end:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/container">
    

    Second, change the above findViewById() statement to look for the correct id

    findViewById(R.id.container);
    

    This should result in a properly assigned layout inside layout.

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

Sidebar

Related Questions

I really need help here. I'm desperate at this point. I have NSOperation that
Hi I'm a real novice at android and really getting desperate at this apparently
Hey, I'm desperate right here. jQuery: $(.rotateme li a).click(function(){ var curid = $(this).attr('id'); $('#box'+curid).fadeIn('slow');
This might be really hacky, but I'm beginning to get desperate Is it possible
I'm really desperate on this one. I'm trying to make a Framework which you
Really ripping my hair out on this one. I have a JAAS Authentication Provider
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
This case is really strange, i've spent 2 whole days to get Twitter Oauth
I'm placing this question here because i'm becoming a little desperate to fix this
I am getting really desperate here. I working with Xcode, trying to implement some

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.