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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:29:01+00:00 2026-06-09T00:29:01+00:00

Force close during activity setup due to null pointer exception. error log: 08-02 12:50:33.913:

  • 0

Force close during activity setup due to null pointer exception.

error log:

08-02 12:50:33.913: E/main(383): Birds clicked on - new activity starting....id
08-02 12:55:22.977: D/AndroidRuntime(383): Shutting down VM
08-02 12:55:22.977: W/dalvikvm(383): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-02 12:55:23.104: E/AndroidRuntime(383): FATAL EXCEPTION: main
08-02 12:55:23.104: E/AndroidRuntime(383): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.kissta.safari/com.kissta.safari.viewscreen}: java.lang.NullPointerException
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.os.Looper.loop(Looper.java:130)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.ActivityThread.main(ActivityThread.java:3683)
08-02 12:55:23.104: E/AndroidRuntime(383):  at java.lang.reflect.Method.invokeNative(Native Method)
08-02 12:55:23.104: E/AndroidRuntime(383):  at java.lang.reflect.Method.invoke(Method.java:507)
08-02 12:55:23.104: E/AndroidRuntime(383):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-02 12:55:23.104: E/AndroidRuntime(383):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-02 12:55:23.104: E/AndroidRuntime(383):  at dalvik.system.NativeStart.main(Native Method)
08-02 12:55:23.104: E/AndroidRuntime(383): Caused by: java.lang.NullPointerException
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.Activity.findViewById(Activity.java:1647)
08-02 12:55:23.104: E/AndroidRuntime(383):  at com.kissta.safari.viewscreen.<init>(viewscreen.java:125)
08-02 12:55:23.104: E/AndroidRuntime(383):  at java.lang.Class.newInstanceImpl(Native Method)
08-02 12:55:23.104: E/AndroidRuntime(383):  at java.lang.Class.newInstance(Class.java:1409)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-02 12:55:23.104: E/AndroidRuntime(383):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
08-02 12:55:23.104: E/AndroidRuntime(383):  ... 11 more

Based on log commands, my app seems to fail when opening either viewscreen or viewxml:

// ...abridged...import android.widget.ImageButton; 

public class main extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainxml);

// ... abridged
ImageButton ibone = (ImageButton) findViewById(R.id.imageButton1);
ibone.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent explicitIntent1 = new Intent(main.this,viewscreen.class);
                explicitIntent1.putExtra("id", 1);
                startActivity(explicitIntent1);
                Log.e("main", "Birds clicked on - new activity starting...." + "id");
            }
        });


....further abridged...

Manifest:

<uses-sdk
    android:minSdkVersion="8"/>

<application
    android:icon="@drawable/iconanimal"
    android:label="@string/app_name"
    android:screenOrientation="landscape"
    android:theme="@style/Theme.Transparent" >
    <activity
        android:name=".splash"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".main"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
    </activity>
    <activity
        android:name=".viewscreen"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
</activity>

</application>

</manifest>

In the viewscreen activity:

package com.kissta.safari;

import java.util.ArrayList;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ViewSwitcher;

public class viewscreen extends Activity implements OnClickListener,
    OnGestureListener {

// references to our image
private animals animalclass = new animals();

int TotalAnimals; // starting from 0 of course (so an 11=12 fruit)
int currentAnimal = 0;

boolean active = true;
long starttime = System.currentTimeMillis();
long timedelay = 50;

ArrayList<Integer> imagearray = new ArrayList<Integer>();
ArrayList<Integer> soundarray = new ArrayList<Integer>();
// ArrayList<String> printarray = new ArrayList<String>();

private ViewSwitcher switcher;
private GestureDetector gesturedetector;
public boolean viewone = true;
public int menuoption;
Handler myHandler = new Handler();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.e("viewscreen1", "xml loading"); // does not reach here
    setContentView(R.layout.viewxml);

The log msg above is never triggered, implying to me that viewxml.xml is never reached(???).

Here is viewxml.xml:

`<?xml version="1.0" encoding="utf-8"?>
<!-- Note:  Can't add more than 2 views to a ViewSwitcher -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fullscreenrelative"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
>

<ViewSwitcher
    android:id="@+id/viewSwitcher"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/bottomtablerow"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center_horizontal|top"
    android:inAnimation="@anim/in_animation"
    android:outAnimation="@anim/out_animation" >

    <RelativeLayout
        android:id="@+id/view1relative"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/swan"
        android:gravity="center_horizontal" >

        <ImageView
            android:id="@+id/view1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/clear32" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/view2relative"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/kangaroo" >

        <ImageView
            android:id="@+id/view2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:src="@drawable/clear32" />
    </RelativeLayout>
</ViewSwitcher>

<TableRow
    android:id="@+id/bottomtablerow"
    android:layout_width="fill_parent"
    android:layout_height="48dp"
    android:layout_alignParentBottom="true"
    android:background="#303030"
    android:gravity="center_horizontal" >

    <ImageButton
        android:id="@+id/btnPrevious"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center_vertical"
        android:layout_weight=".2"
        android:background="@drawable/whiteleft"
        android:textStyle="bold" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight=".1"
        android:src="@drawable/clear" />

    <TextView
        android:id="@+id/textll"
        android:layout_width="wrap_content"
        android:layout_height="44dp"
        android:layout_gravity="center_horizontal|top"
        android:layout_weight="1"
        android:gravity="center"
        android:includeFontPadding="false"
        android:padding="10dip"
        android:text="@string/app_name"
        android:textColor="#FFFFFF"
        android:textSize="25sp" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight=".1"
        android:src="@drawable/clear" />

    <ImageButton
        android:id="@+id/btnNext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|center_vertical"
        android:layout_weight=".2"
        android:background="@drawable/whiteright"
        android:textStyle="bold" />
</TableRow>

</RelativeLayout>`

PS I am now also getting an AVD error which may be unrelated:
“emulator: ERROR: Could not load OpenGLES emulation library: Could not load DLL!”
I don’t believe I am using OpenGL at all though.
see common bug report at http://code.google.com/p/android/issues/detail?id=33336

PSS my app is also rejecting the use of non-google api VMs

PSS here is the full main file as requested:
package com.kissta.safari;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;

public class main extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainxml);
    // android:tileMode="repeat"

    Log.e("main", "main all good");

    SoundManager.getInstance();
    SoundManager.initSounds(main.this);
    SoundManager.loadSounds();
    Log.e("main", "sm LoadSounds worked, all done.");

        // SECTION FOR GAME CHOICE BUTTONS!!!!!!!!!
        // ***
        ImageButton ibone = (ImageButton) findViewById(R.id.imageButton1);
        ibone.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent explicitIntent1 = new Intent(main.this,viewscreen.class);
                explicitIntent1.putExtra("id", 1);
                startActivity(explicitIntent1);
                Log.e("main", "Birds clicked on - new activity starting...." + "id"); // it gets this far perfectly fine
            }
        });

        // ***

        ImageButton ibtwo = (ImageButton) findViewById(R.id.imageButton2);
        ibtwo.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Playsound2.stop();
                Intent explicitIntent2 = new Intent(main.this,
                        viewscreen.class);
                explicitIntent2.putExtra("id", 2);
                startActivity(explicitIntent2);
            }
        });

        // ***

        ImageButton ibthree = (ImageButton) findViewById(R.id.imageButton3);
        ibthree.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Playsound2.stop();
                Intent explicitIntent3 = new Intent(main.this,
                        viewscreen.class);
                explicitIntent3.putExtra("id", 3);
                startActivity(explicitIntent3);
            }
        });

        // ***

        ImageButton ibfour = (ImageButton) findViewById(R.id.imageButton4);
        ibfour.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Playsound2.stop();
                Intent explicitIntent4 = new Intent(main.this,
                        viewscreen.class);
                explicitIntent4.putExtra("id", 4);
                startActivity(explicitIntent4);
            }
        });

        ImageButton ibfive = (ImageButton) findViewById(R.id.imageButton5);
        ibfive.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Playsound2.stop();
                Intent explicitIntent5 = new Intent(main.this,
                        viewscreen.class);
                explicitIntent5.putExtra("id", 5);
                startActivity(explicitIntent5);
            }
        });

        ImageButton ibsix = (ImageButton) findViewById(R.id.imageButton6); // settings - adjust
        ibsix.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Playsound2.stop();
                Intent explicitIntent6 = new Intent(main.this,
                        viewscreen.class);
                explicitIntent6.putExtra("id", 6);
                startActivity(explicitIntent6);
            }
        });

        ImageButton ibsev = (ImageButton) findViewById(R.id.imageButtonau); // settings - adjust
        ibsev.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Playsound2.stop();
                Intent explicitIntent6 = new Intent(main.this,
                        viewscreen.class);
                explicitIntent6.putExtra("id", 7);
                startActivity(explicitIntent6);
            }
        });




        // / *************** END OF GAME CHOICE BUTTONS


    }



}
  • 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-09T00:29:02+00:00Added an answer on June 9, 2026 at 12:29 am
    Intent explicitIntent1 = new Intent(main.this,viewscreen.class);
    explicitIntent1.putExtra("id", 1);
    startActivity(explicitIntent1);
    Log.e("main", "this finished ok"); // app gets to here fine
    

    Afer this code, there is come which is something like

    findViewById(..
    

    Check if this ID exist in your xml

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

Sidebar

Related Questions

my app is getting force close randomly. And every time error can not be
with this code, my program just force close(error) ***public View x = findViewById(R.string.nfoname);*** @Override
I have a weird error, I am not able to find a force close
I got force close error when opening my install app, herewith i enclosed my
I want to log some details when the Application gets force close itself. Ya,
How to quit the app or force close the app when multiple activity running
Trying to develop hello world, but getting force close error on emulator. thanks in
I'm Trying to start the saveBookmark activity and I get Force Close for some
Is there a way to notify an activity/service of a force-close request right before
Can someone please explain how to understand a logcat from an android force close.

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.