Application has closed unexpectedly. Please try again.

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Application has closed unexpectedly. Please try again.

Postby Sondar » Wed Aug 05, 2009 10:45 am

I am very new to Java and Android in general. When I try to run my app i get that error message. The app is very simple. It should display some text after the person clicks an image button. Here is a picture of the Log:

http://yfrog.com/5fandroiderrorp

Thanks In Advance
Sondar
Freshman
Freshman
 
Posts: 2
Joined: Wed Aug 05, 2009 10:41 am

Top

Postby Sondar » Wed Aug 05, 2009 7:02 pm

I think I fixed this problem but a new one has appeared:

In this code:

package hand.gun.app;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class HandGunApp extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button GunButton = (Button)findViewById(R.id.GunButton);
GunButton.setOnClickListener(new OnClickListener() {
@Override

public void onClick(View arg0) {
MediaPlayer mp = MediaPlayer.create
(MusicPlayer.this, R.raw.gunshot);
mp.prepare();
mp.start();
// i.e. react on the end of the music-file:
mp.setOnCompletionListener(new OnCompletionListener(){

// @Override
public void onCompletion(MediaPlayer arg0) {
// File has ended !!!
}
});
}
});
}
}

It says on the line:

(MusicPlayer.this, R.raw.gunshot);

Music Player cannot be resolved to a type and R.raw cannot be resolved.

Any Ideas?
Sondar
Freshman
Freshman
 
Posts: 2
Joined: Wed Aug 05, 2009 10:41 am

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests