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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:02:56+00:00 2026-05-31T19:02:56+00:00

This basic app which was given to me as an project should run quite

  • 0

This basic app which was given to me as an project should run quite easily is giving me the hardest time.
Well,I commented everything in my activity and still the same error occurs. So I think that the error is somewhere in the xml files. Please help if you can spot the error.And yeah,the main file is pretty big,but please go through it.

Main.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >



<Gallery 
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_marginTop="2dp">

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="Length" />
</RelativeLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_marginTop="5dp">


<Spinner
    android:id="@+id/spinner1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />

<Spinner
    android:id="@+id/spinner2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" />

</RelativeLayout>


<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_marginTop="5dp">

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="FROM" android:textColor="#FFFF00"/>

<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="15dp"
    android:layout_toRightOf="@+id/textView2"
    android:ems="10"
    android:inputType="numberDecimal" android:clickable="false"  android:focusable="false" android:focusableInTouchMode="false">

    <requestFocus />
</EditText>

</RelativeLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="TO      " android:textColor="#FFFF00" android:clickable="false"  android:focusable="false" android:focusableInTouchMode="false"/>

<EditText
    android:id="@+id/editText2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="15dp"
    android:layout_toRightOf="@+id/textView3"
    android:ems="10"
    android:inputType="numberDecimal"/>

</RelativeLayout>


<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center_horizontal"     android:layout_marginTop="5dp">

<Button
    android:id="@+id/b1"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="1" 
    />


<Button
    android:id="@+id/b2"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b1"
    android:text="2" />

 <Button
    android:id="@+id/b3"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"

    android:layout_toRightOf="@+id/b2"
    android:text="3" />

</RelativeLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center">

<Button
    android:id="@+id/b4"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="4" />

<Button
   android:id="@+id/b5"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b4"

    android:text="5" />

<Button
    android:id="@+id/b6"
    android:layout_width="70dp"
    android:layout_height="40dp"

    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b5"
    android:text="6"  />

</RelativeLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center">

<Button
    android:id="@+id/b7"

    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="7" />

<Button
   android:id="@+id/b8"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b7"
    android:text="8" />

<Button
    android:id="@+id/b9"

    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b8"
    android:text="9" />

</RelativeLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center">

<Button

    android:id="@+id/bdot"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="." />

<Button
    android:id="@+id/b0"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/bdot"
    android:text="0" />

<Button
    android:id="@+id/bc"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"

    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b0"
    android:text="C" />

</RelativeLayout>

</LinearLayout>

strings.xml

<?xml version="1.0" encoding="utf-8"?>

<string name="hello">Hello World, GurkhaActivity!</string>
<string name="app_name">Gurkha</string>
<string-array name="length">
    <item>Metre</item>
    <item>Centimetre</item>
    <item>Kilometre</item>
</string-array>
    <string-array name="weight">
    <item>Gram</item>
    <item>Kilogram</item>
    <item>Milligram</item>
</string-array>

</resources>

attrs.xml //For Gallery

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="HelloGallery">
    <attr name="android:galleryItemBackground" />
</declare-styleable>
</resources>

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sanjay.gurkha"
android:versionCode="1"
android:versionName="1.0" >

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".GurkhaActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

Logcat :

03-24 01:30:03.729: D/AndroidRuntime(631): Shutting down VM
03-24 01:30:03.769: W/dalvikvm(631): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
03-24 01:30:03.939: E/AndroidRuntime(631): FATAL EXCEPTION: main
03-24 01:30:03.939: E/AndroidRuntime(631): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sanjay.gurkha/com.sanjay.gurkha.GurkhaActivity}: java.lang.NullPointerException
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.os.Looper.loop(Looper.java:137)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.reflect.Method.invokeNative(Native Method)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.reflect.Method.invoke(Method.java:511)
03-24 01:30:03.939: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-24 01:30:03.939: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-24 01:30:03.939: E/AndroidRuntime(631):  at dalvik.system.NativeStart.main(Native Method)
03-24 01:30:03.939: E/AndroidRuntime(631): Caused by: java.lang.NullPointerException
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.Activity.findViewById(Activity.java:1794)
03-24 01:30:03.939: E/AndroidRuntime(631):  at com.sanjay.gurkha.GurkhaActivity.<init>(GurkhaActivity.java:28)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.Class.newInstanceImpl(Native Method)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.Class.newInstance(Class.java:1319)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-24 01:30:03.939: E/AndroidRuntime(631):  ... 11 more
  • 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-31T19:02:57+00:00Added an answer on May 31, 2026 at 7:02 pm

    I assume your label above the Main.xml file is just a typo in the question and should be main.xml since I don’t think it would compile if that was wrong.

    I’m pretty sure the culprit is these lines:

    EditText et1=(EditText) findViewById(com.sanjay.gurkha.R.id.editText1);
    
    EditText et2=(EditText) findViewById(com.sanjay.gurkha.R.id.editText2); 
    

    Since these are outside any method they get called when the object is constructed (and before the onCreate method) hence the mention of the constructor (<init>) in the stack trace.

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

Sidebar

Related Questions

This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
I'm trying to learn this basic thing about processors that should be taught in
I'm trying to create an app which scans ports of given IP address individually
There's this web app, which relies on a sort of data access library (simple
I have an ASP.NET MVC web app which has a really basic subscription system
I've created this basic 3D Demo using OpenGL/SDL. I handled the keyboard callback so
Forgive my ignorance in asking this basic question but I've become so used to
This is basic stuff, but I'm somewhat unfamiliar with VBA and the Word/Access object
I am new to Scala, just started learning, so this is basic beginner question.
This is very basic stuff , but here goes. I find that I am

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.