-14

I've designed first application in android by following the tips mentioned in http://developer.android.com/training/basics/firstapp/starting-activity.html#AddToManifest

When I type something and press Send button it displays

Unfortunately app stop working

and the corresponding log is as below

10-10 12:10:04.029: D/dalvikvm(550): Not late-enabling CheckJNI (already on)
10-10 12:10:06.549: D/gralloc_goldfish(550): Emulator without GPU emulation detected.
10-10 12:10:26.169: D/AndroidRuntime(550): Shutting down VM
10-10 12:10:26.169: W/dalvikvm(550): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
10-10 12:10:26.229: E/AndroidRuntime(550): FATAL EXCEPTION: main
10-10 12:10:26.229: E/AndroidRuntime(550): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f080000 for fragment PlaceholderFragment{4108e7c8 #0 id=0x7f080000}
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.ActivityThread.access$600(ActivityThread.java:122)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.os.Looper.loop(Looper.java:137)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.ActivityThread.main(ActivityThread.java:4340)
10-10 12:10:26.229: E/AndroidRuntime(550):  at java.lang.reflect.Method.invokeNative(Native Method)
10-10 12:10:26.229: E/AndroidRuntime(550):  at java.lang.reflect.Method.invoke(Method.java:511)
10-10 12:10:26.229: E/AndroidRuntime(550):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-10 12:10:26.229: E/AndroidRuntime(550):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-10 12:10:26.229: E/AndroidRuntime(550):  at dalvik.system.NativeStart.main(Native Method)
10-10 12:10:26.229: E/AndroidRuntime(550): Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f080000 for fragment PlaceholderFragment{4108e7c8 #0 id=0x7f080000}
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:789)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:998)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.BackStackRecord.run(BackStackRecord.java:622)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1330)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.Activity.performStart(Activity.java:4474)
10-10 12:10:26.229: E/AndroidRuntime(550):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928)
10-10 12:10:26.229: E/AndroidRuntime(550):  ... 11 more
10-10 12:10:31.099: I/Process(550): Sending signal. PID: 550 SIG: 9

The code:

public void sendMessage(View view) { 
   Intent intent=new Intent(this, DisplayMessageActivity.class); 
   EditText editText=(EditText)findViewById(R.id.edit_message); 
   String message=editText.toString().toString(); 
   intent.putExtra(EXTRA_MESSAGE, message); 
   startActivity(intent); 
}

DisplayMessageActivity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_message);
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment()).commit();
    }
    Intent intent=getIntent();
    String message=intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    
    TextView textView=new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);
    
    setContentView(textView);
}

What is the problem? Can anyone give me a suggestion as to what's going wrong.

lejlun
  • 3,363
  • 2
  • 12
  • 30
  • 1
    Show some code atleast. – GrIsHu Oct 10 '14 at 07:09
  • 1
    Please just write code what you written in send Button click, so people can understand what you written wrong and don't need to display this much of error stack on question Or copy your activity class :) – khurram Oct 10 '14 at 07:11
  • http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – Blackbelt Oct 10 '14 at 07:33
  • This is the code of send Button public void sendMessage(View view){ Intent intent=new Intent(this, DisplayMessageActivity.class); EditText editText=(EditText)findViewById(R.id.edit_message); String message=editText.toString().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); } – Ramprakash Oct 10 '14 at 07:43
  • The problem is in `DisplayMessageActivity` and likely a fragment transaction in `onCreate()` there. – laalto Oct 10 '14 at 07:59
  • What is the problem?? – Ramprakash Oct 10 '14 at 08:02
  • 1
    the problem is Fragment related. The system is looking for `R.id.container` in `activity_display_message`, and that is probably not there. If you are not explicitly using Fragment, comment out `if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); }` – Blackbelt Oct 10 '14 at 08:35
  • How come this question is not closed after -12 votes? –  Aug 28 '20 at 15:01

2 Answers2

0

I looked at the link you pasted here and I think this should solve your problem:

in your activity_display_message.xml you have to add the following code

android:id="@+id/activity_display_message
lejlun
  • 3,363
  • 2
  • 12
  • 30
Rahul
  • 78
  • 14
-2

In Android SDK Tools R15 you can enable GPU emulation.

You need to create a new emulator virtual device and set GPU emulation to true in Hardware properties.

GPU enabling is now is allowed directly through Emulator Creation option. Go to Window --> Android Virtual Device Manager --> new. Now remember to checkmark Use GPU host, then you will have a pretty fast working emulator with GPU enabled.

NIMISHAN
  • 1,267
  • 3
  • 19
  • 29
Shahbaz Akhtar
  • 247
  • 2
  • 8