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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:12:47+00:00 2026-06-14T03:12:47+00:00

my app always crashes when I press a button. I’m new to android, so

  • 0

my app always crashes when I press a button. I’m new to android, so could you help me?

When the user presses the button, it is supposed to increment an int and then display it in a textView.

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="sendMessage"
        android:text="@string/button_send" />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/text"
        android:textSize="30sp"
        tools:context=".DisplayMessageActivity" />

    <!-- android:visibility="invisible" -->

    <TextView
        android:id="@+id/val"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/text"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="37dp"
        android:text="            " />

</RelativeLayout>

MainActivity.java

package com.example.myfirstapp;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
    public final static String  EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
    public int mult = 1;

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    /** Called when the user clicks on the Send button */
    public void sendMessage(View view)
    {
        //Intent intent = new Intent(this, DisplayMessageActivity.class);
        //TextView text = (TextView) findViewById(R.id.text);

        TextView val = (TextView) findViewById(R.id.val);
        val.setText(mult);
        mult+=1;
        //EditText editText = (EditText) findViewById(R.id.edit_message);
        //String message = editText.getText().toString();
        //intent.putExtra(EXTRA_MESSAGE, message);
        //startActivity(intent);
    }
}

here is the crash log

11-07 14:23:05.663: I/Choreographer(1126): Skipped 32 frames!  The application may be doing too much work on its main thread.
11-07 14:23:05.898: D/gralloc_goldfish(1126): Emulator without GPU emulation detected.
11-07 14:23:10.543: I/Choreographer(1126): Skipped 51 frames!  The application may be doing too much work on its main thread.
11-07 14:23:11.076: W/ResourceType(1126): No package identifier when getting value for resource number 0x00000001
11-07 14:23:11.083: D/AndroidRuntime(1126): Shutting down VM
11-07 14:23:11.083: W/dalvikvm(1126): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-07 14:23:11.263: E/AndroidRuntime(1126): FATAL EXCEPTION: main
11-07 14:23:11.263: E/AndroidRuntime(1126): java.lang.IllegalStateException: Could not execute method of the activity
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.view.View$1.onClick(View.java:3591)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.view.View.performClick(View.java:4084)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.view.View$PerformClick.run(View.java:16966)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.os.Handler.handleCallback(Handler.java:615)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.os.Looper.loop(Looper.java:137)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at java.lang.reflect.Method.invokeNative(Native Method)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at java.lang.reflect.Method.invoke(Method.java:511)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at dalvik.system.NativeStart.main(Native Method)
11-07 14:23:11.263: E/AndroidRuntime(1126): Caused by: java.lang.reflect.InvocationTargetException
11-07 14:23:11.263: E/AndroidRuntime(1126):     at java.lang.reflect.Method.invokeNative(Native Method)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at java.lang.reflect.Method.invoke(Method.java:511)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.view.View$1.onClick(View.java:3586)
11-07 14:23:11.263: E/AndroidRuntime(1126):     ... 11 more
11-07 14:23:11.263: E/AndroidRuntime(1126): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.content.res.Resources.getText(Resources.java:229)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at android.widget.TextView.setText(TextView.java:3620)
11-07 14:23:11.263: E/AndroidRuntime(1126):     at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:34)
11-07 14:23:11.263: E/AndroidRuntime(1126):     ... 14 more
11-07 14:23:15.013: I/Process(1126): Sending signal. PID: 1126 SIG: 9
  • 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-14T03:12:49+00:00Added an answer on June 14, 2026 at 3:12 am

    I believe the setText method looks for a resource if you pass in an int. You need to change the variable mult to a String before you can use setText. Either of the following will work:

    val.setText("" + mult);
    

    Or

    val.setText(Integer.toString(mult));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My UIActivityIndicatorView always crashes my app. When I press my download button, the indicator
I am currently developing an android app, there is always unexpected exception popup when
The Android Uri.normaliseScheme() method always crashes. It doesn't even throw an exception. I have
I am building a tablet app in Android 3.0 that should always be displayed
My iPad app always gives memory warning level 1 or 2, but NEVER crashes.
Retrieving a value from standardUserDefaults using integerForKey after saving with setInteger:forKey always crashes app.
An app I'm writing always crashes on a clients computer, but I don't get
HELP please this is just a simple android app I am developing, it's meant
My client wants their app to always show a WARNING screen when the application
Guys, I have a basic WPF application. Contains App.xaml as always and a Mainwindow.xaml.

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.