按钮操作使应用程序崩溃[重复]

Posted

技术标签:

【中文标题】按钮操作使应用程序崩溃[重复]【英文标题】:button action crashes the application [duplicate] 【发布时间】:2013-09-17 16:59:40 【问题描述】:

您好,我在主菜单上创建了一个类似“保存笔记”的按钮....但是现在当我启动应用程序并单击它时,我的整个应用程序崩溃了。主菜单上的休息按钮工作正常。

主菜单类

public class NUGA_MainMenuActivity extends Activity 

    SoundPool mpool;
    int mlogon;
    Button mBtn1;
    Button mBtn2;
    Button mBtn3;
    Button mBtn4;
    Button mBtn5;
    Button mHistoryButton;
    Animation anim = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.mainmenu);

        mHistoryButton = (Button) findViewById(R.id.takeashot);
        mBtn1 = (Button) findViewById(R.id.BtnDisplay);
        mBtn2 = (Button) findViewById(R.id.BtnSlave);
        mHistoryButton.setOnClickListener(mClickListener);
        mBtn3 = (Button) findViewById(R.id.takehelp);
        mBtn4 = (Button) findViewById(R.id.aboutus);
        mBtn5 = (Button) findViewById(R.id.savenotes);

        mBtn1.setOnClickListener(mClickListener);
        mBtn2.setOnClickListener(mClickListener);
        mBtn3.setOnClickListener(mClickListener);
        mBtn4.setOnClickListener(mClickListener);
        mBtn5.setOnClickListener(mClickListener);

        mpool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
        mlogon = mpool.load(this, R.raw.logon, 1);

        anim = new AlphaAnimation(0, 1);
        anim.setDuration(1500);

        mBtn1.startAnimation(anim);
        mBtn2.startAnimation(anim);
        mBtn3.startAnimation(anim);
        mBtn4.startAnimation(anim);
        mBtn5.startAnimation(anim);

        mpool.play(mlogon, 1, 1, 0, 0, 1);    
    

    Button.OnClickListener mClickListener = new View.OnClickListener() 

        Animation anim = null;

        @Override
        public void onClick(View v) 
            Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            vibe.vibrate(60);

            switch (v.getId()) 
                case R.id.BtnDisplay:
                    mpool.play(mlogon, 1, 1, 0, 0, 1);
                    anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f,
                            Animation.RELATIVE_TO_SELF, 0.5f);
                    anim.setDuration(100);
                    mBtn1.startAnimation(anim);
                    Intent intent = new Intent(NUGA_MainMenuActivity.this, FileSiganlDisplay.class);
                    startActivity(intent);
                    //overridePendingTransition(R.anim.zoom_enter,R.anim.zoom_exit);
                    overridePendingTransition(R.anim.fade, R.anim.hold);
                    break;

                case R.id.BtnSlave:

                    mpool.play(mlogon, 1, 1, 0, 0, 1);
                    anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f,
                            Animation.RELATIVE_TO_SELF, 0.5f);
                    anim.setDuration(100);
                    mBtn2.startAnimation(anim);
                    Intent intent1 = new Intent(NUGA_MainMenuActivity.this,
                            BTSmartSlavemodule.class);
                    startActivity(intent1);
                    //overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
                    overridePendingTransition(R.anim.fade, R.anim.hold);

                    break;
                case R.id.takeashot:
                    //snapFunction();
                    Intent intent2 = new Intent(NUGA_MainMenuActivity.this, ImagesActivity.class);
                    startActivity(intent2);
                    break;

                case R.id.takehelp:
                    mpool.play(mlogon, 1, 1, 0, 0, 1);
                    anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f,
                            Animation.RELATIVE_TO_SELF, 0.5f);
                    anim.setDuration(100);
                    mBtn3.startAnimation(anim);
                    Intent intent3 = new Intent(NUGA_MainMenuActivity.this, HelpActivity.class);
                    startActivity(intent3);
                    overridePendingTransition(R.anim.fade, R.anim.hold);
                    break;

                case R.id.aboutus:
                    mpool.play(mlogon, 1, 1, 0, 0, 1);
                    anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f,
                            Animation.RELATIVE_TO_SELF, 0.5f);
                    anim.setDuration(100);
                    mBtn4.startAnimation(anim);
                    Intent intent4 = new Intent(NUGA_MainMenuActivity.this, AboutDevice.class);
                    startActivity(intent4);
                    overridePendingTransition(R.anim.fade, R.anim.hold);
                    break;

                case R.id.savenotes:
                    mpool.play(mlogon, 1, 1, 0, 0, 1);
                    anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f,
                            Animation.RELATIVE_TO_SELF, 0.5f);
                    anim.setDuration(100);
                    mBtn4.startAnimation(anim);
                    Intent intent5 = new Intent(NUGA_MainMenuActivity.this, NotesList.class);
                    startActivity(intent5);
                    overridePendingTransition(R.anim.fade, R.anim.hold);
                    break;

                default:
                    break;
            

        
    ;

    public void snapFunction() 

        Date currentTime = new Date();
        final SimpleDateFormat sdf =
                new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss");
        // Give it to me in GMT time.
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        //System.out.println("GMT time: " + sdf.format(currentTime));
        String ss = sdf.format(currentTime);
        Log.v("current time", ss);

        View mContent = findViewById(R.id.screenLayout);
        mContent.setDrawingCacheEnabled(true);
        Bitmap bitmap = mContent.getDrawingCache();
        File sdCardDirectory = Environment.getExternalStorageDirectory();
        File image = new File(sdCardDirectory, ss + ".jpg");
        name = ss;
        // File file = new File("/sdcard/"+String.valueOf(currentId)+".png");           
        
            if (!image.exists()) 
                try 

                    image.createNewFile();
                    FileOutputStream ostream = new FileOutputStream(image);
                    bitmap.compress(CompressFormat.PNG, 10, ostream);
                    ostream.close();
                    mContent.invalidate();
                    DB.insert(ss);
                    Cursor cursor = DB.retrieveFav();
                    if (cursor != null) 
                        if (cursor.moveToFirst()) 
                            new Toast(NUGA_MainMenuActivity.this)
                                    .makeText(NUGA_MainMenuActivity.this,
                                            "DB contains:" + cursor.getCount() + "images",
                                            Toast.LENGTH_LONG).show();
                        
                    
                    cursor.close();
                 catch (IOException e) 
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                
            


        
    

    static String name = "";

androidManifest 文件

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

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

    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:name="helog.diwesh.NugaBest.MyApplication" 
        android:debuggable="true"
        android:icon="@drawable/nuga"
        android:label="@string/app_name" >
        <activity
            android:name="helog.diwesh.NugaBest.NUGA_HealthCareActivity_Intro"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        // 4. Layout Management

        <activity
            android:name="helog.diwesh.NugaBest.FileSiganlDisplay"
            android:label="FileSiganlDisplay" />
        <activity
            android:name="helog.diwesh.NugaBest.NUGA_WebJoinActivity"
            android:label="NUGA_WebJoinActivity"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="helog.diwesh.NugaBest.NUGA_MainMenuActivity"
            android:label="NUGA_MainMenuActivity" />
        <activity
            android:name="helog.diwesh.NugaBest.BTSmartSlavemodule"
            android:configChanges="orientation|keyboardHidden"
            android:label="SmartSlavemodule" />
        <activity
            android:name="helog.diwesh.NugaBest.BTDeviceListActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/select_device"
            android:theme="@android:style/Theme.Dialog" />

        <activity
            android:name="helog.diwesh.NugaBest.SnapActivity"
            android:label="@string/title_activity_snap" >
        </activity>
        <activity
            android:name="helog.diwesh.NugaBest.ImagesActivity"
            android:label="@string/title_activity_images" >
        </activity>
        <activity
            android:name="helog.diwesh.NugaBest.HelpActivity"
            android:label="@string/Help" >
        </activity>
        <activity
            android:name="helog.diwesh.NugaBest.AboutDevice"
            android:label="@string/aboutus" >
        </activity>




        // Notepad Application


        <provider android:name="NotePadProvider"
            android:authorities="com.google.provider.NotePad"
            android:exported="false">
            <grant-uri-permission android:pathPattern=".*" />
        </provider>

         <activity android:name="NotesList" android:label="@string/title_notes_list">

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <action android:name="android.intent.action.PICK" />

                <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>
        </activity>

        <activity android:name="NoteEditor"
            android:theme="@android:style/Theme.Holo.Light"
            android:screenOrientation="sensor"
            android:configChanges="keyboardHidden|orientation"
        >
            <!-- This filter says that we can view or edit the data of
                 a single note -->
            <intent-filter android:label="@string/resolve_edit">
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <action android:name="helog.diwesh.NugaBest.action.EDIT_NOTE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>

            <!-- This filter says that we can create a new note inside
                 of a directory of notes.  The INSERT action creates an
                 empty note; the PASTE action initializes a new note from
                 the current contents of the clipboard. -->
            <intent-filter>
                <action android:name="android.intent.action.INSERT" />
                <action android:name="android.intent.action.PASTE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
            </intent-filter>

        </activity>

        <activity android:name="TitleEditor"
            android:label="@string/title_edit_title"
            android:icon="@drawable/ic_menu_edit"
            android:theme="@android:style/Theme.Holo.Dialog"
            android:windowSoftInputMode="stateVisible">
            <!-- This activity implements an alternative action that can be
                 performed on notes: editing their title.  It can be used as
                 a default operation if the user invokes this action, and is
                 available as an alternative action for any note data. -->
            <intent-filter android:label="@string/resolve_title">
                <!-- This is the action we perform.  It is a custom action we
                     define for our application, not a generic VIEW or EDIT
                     action since we are not a general note viewer/editor. -->
                <action android:name="helog.diwesh.NugaBest.action.EDIT_TITLE" />
                <!-- DEFAULT: execute if being directly invoked. -->
                <category android:name="android.intent.category.DEFAULT" />
                <!-- ALTERNATIVE: show as an alternative action when the user is
                     working with this type of data. -->
                <category android:name="android.intent.category.ALTERNATIVE" />
                <!-- SELECTED_ALTERNATIVE: show as an alternative action the user
                     can perform when selecting this type of data. -->
                <category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
                <!-- This is the data type we operate on. -->
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>
        </activity>

        <activity android:name="NotesLiveFolder" android:label="@string/live_folder_name"
            android:icon="@drawable/live_folder_notes">
            <intent-filter>
                <action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

</manifest>

LogCat 错误

[2013-09-13 11:10:59 - NotesList] ------------------------------
[2013-09-13 11:10:59 - NotesList] Android Launch!
[2013-09-13 11:10:59 - NotesList] adb is running normally.
[2013-09-13 11:10:59 - NotesList] Performing com.example.android.notepad.NotesList activity launch
[2013-09-13 11:10:59 - NotesList] Failed to find an AVD compatible with target 'Google APIs'.
[2013-09-13 11:11:01 - NotesList] Still no compatible AVDs with target 'Google APIs': Aborting launch.
[2013-09-13 11:11:01 - NotesList] Performing com.example.android.notepad.NotesList activity launch
[2013-09-13 11:11:02 - NotesList] Launching a new emulator with Virtual Device 'Testing'
[2013-09-13 11:11:05 - Emulator] emulator: warning: opening audio output failed
[2013-09-13 11:11:05 - Emulator] 
[2013-09-13 11:11:05 - NotesList] New emulator found: emulator-5554
[2013-09-13 11:11:05 - NotesList] Waiting for HOME ('android.process.acore') to be launched...
[2013-09-13 11:12:00 - NotesList] HOME is up on device 'emulator-5554'
[2013-09-13 11:12:00 - NotesList] Uploading NotesList.apk onto device 'emulator-5554'
[2013-09-13 11:12:00 - NotesList] Installing NotesList.apk...
[2013-09-13 11:12:31 - NotesList] Success!
[2013-09-13 11:12:31 - NotesList] Starting activity com.example.android.notepad.NotesList on device emulator-5554
[2013-09-13 11:12:32 - NotesList] ActivityManager: Starting: Intent  act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.notepad/.NotesList 
[2013-09-13 11:44:51 - NotesList] ------------------------------
[2013-09-13 11:44:51 - NotesList] Android Launch!
[2013-09-13 11:44:51 - NotesList] adb is running normally.
[2013-09-13 11:44:51 - NotesList] Performing com.example.android.notepad.NotesList activity launch
[2013-09-13 11:44:51 - NotesList] Failed to find an AVD compatible with target 'Google APIs'.
[2013-09-13 11:44:52 - NotesList] Still no compatible AVDs with target 'Google APIs': Aborting launch.
[2013-09-13 11:44:52 - NotesList] Performing com.example.android.notepad.NotesList activity launch
[2013-09-13 11:44:56 - NotesList] Launching a new emulator with Virtual Device 'Testing'
[2013-09-13 11:44:56 - Emulator] emulator: warning: opening audio output failed
[2013-09-13 11:44:56 - Emulator] 
[2013-09-13 11:44:56 - NotesList] New emulator found: emulator-5554
[2013-09-13 11:44:56 - NotesList] Waiting for HOME ('android.process.acore') to be launched...
[2013-09-13 11:45:29 - NotesList] HOME is up on device 'emulator-5554'
[2013-09-13 11:45:29 - NotesList] Uploading NotesList.apk onto device 'emulator-5554'
[2013-09-13 11:45:29 - NotesList] Installing NotesList.apk...
[2013-09-13 11:45:57 - NotesList] Success!
[2013-09-13 11:45:57 - NotesList] Starting activity com.example.android.notepad.NotesList on device emulator-5554
[2013-09-13 11:45:59 - NotesList] ActivityManager: Starting: Intent  act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.notepad/.NotesList 
[2013-09-13 11:56:44 - NotesList] ------------------------------
[2013-09-13 11:56:44 - NotesList] Android Launch!
[2013-09-13 11:56:44 - NotesList] adb is running normally.
[2013-09-13 11:56:44 - NotesList] Performing com.example.android.notepad.NotesList activity launch
[2013-09-13 11:56:44 - NotesList] Failed to find an AVD compatible with target 'Google APIs'.
[2013-09-13 11:56:45 - NotesList] Still no compatible AVDs with target 'Google APIs': Aborting launch.
[2013-09-13 11:56:45 - NotesList] Performing com.example.android.notepad.NotesList activity launch
[2013-09-13 11:56:47 - NotesList] Launching a new emulator with Virtual Device 'Testing'
[2013-09-13 11:56:48 - Emulator] emulator: warning: opening audio output failed
[2013-09-13 11:56:48 - Emulator] 
[2013-09-13 11:56:48 - NotesList] New emulator found: emulator-5554
[2013-09-13 11:56:48 - NotesList] Waiting for HOME ('android.process.acore') to be launched...
[2013-09-13 11:57:20 - NotesList] HOME is up on device 'emulator-5554'
[2013-09-13 11:57:20 - NotesList] Uploading NotesList.apk onto device 'emulator-5554'
[2013-09-13 11:57:20 - NotesList] Installing NotesList.apk...
[2013-09-13 11:57:50 - NotesList] Success!
[2013-09-13 11:57:50 - NotesList] Starting activity com.example.android.notepad.NotesList on device emulator-5554
[2013-09-13 11:57:51 - NotesList] ActivityManager: Starting: Intent  act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.notepad/.NotesList 
[2013-09-13 13:47:46 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] W/ResourceType( 9556): ResXMLTree_node header size 0 is too small.
[2013-09-13 13:47:46 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] W/ResourceType( 9556): Bad XML block: node attributes use 0x7814 bytes, only have 0x14 bytes
[2013-09-13 13:47:46 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\editor_options_menu.xml:3: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_save').
[2013-09-13 13:47:46 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\editor_options_menu.xml:8: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_revert').
[2013-09-13 13:47:46 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\editor_options_menu.xml:11: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_delete').
[2013-09-13 13:47:46 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\list_options_menu.xml:4: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_compose').
[2013-09-13 13:47:46 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\list_options_menu.xml:11: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_compose').
[2013-09-13 13:50:39 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] W/ResourceType( 9284): ResXMLTree_node header size 0 is too small.
[2013-09-13 13:50:39 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] W/ResourceType( 9284): Bad XML block: node attributes use 0x7814 bytes, only have 0x14 bytes
[2013-09-13 13:50:39 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\editor_options_menu.xml:3: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_save').
[2013-09-13 13:50:39 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\editor_options_menu.xml:8: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_revert').
[2013-09-13 13:50:39 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\editor_options_menu.xml:11: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_delete').
[2013-09-13 13:50:39 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\list_options_menu.xml:4: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_compose').
[2013-09-13 13:50:39 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] D:\Latest try\Nuga Hellog Final\Nuga Hellog Final\res\menu\list_options_menu.xml:11: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_compose').
[2013-09-13 14:16:33 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] ------------------------------
[2013-09-13 14:16:33 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Android Launch!
[2013-09-13 14:16:33 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] adb is running normally.
[2013-09-13 14:16:33 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Performing helog.diwesh.NugaBest.NUGA_HealthCareActivity_Intro activity launch
[2013-09-13 14:16:33 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Failed to find an AVD compatible with target 'Google APIs'.
[2013-09-13 14:16:34 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Still no compatible AVDs with target 'Google APIs': Aborting launch.
[2013-09-13 14:16:34 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Performing helog.diwesh.NugaBest.NUGA_HealthCareActivity_Intro activity launch
[2013-09-13 14:16:36 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Launching a new emulator with Virtual Device 'Testing'
[2013-09-13 14:16:41 - Emulator] emulator: warning: opening audio output failed
[2013-09-13 14:16:41 - Emulator] 
[2013-09-13 14:16:41 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] New emulator found: emulator-5554
[2013-09-13 14:16:41 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Waiting for HOME ('android.process.acore') to be launched...
[2013-09-13 14:17:40 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] HOME is up on device 'emulator-5554'
[2013-09-13 14:17:40 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Uploading NUGA_HealthCare_bluetooth_ver4_PID_verICS.apk onto device 'emulator-5554'
[2013-09-13 14:17:53 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Installing NUGA_HealthCare_bluetooth_ver4_PID_verICS.apk...
[2013-09-13 14:18:32 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Success!
[2013-09-13 14:18:32 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Starting activity helog.diwesh.NugaBest.NUGA_HealthCareActivity_Intro on device emulator-5554
[2013-09-13 14:18:34 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] ActivityManager: Starting: Intent  act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=hellog.diwesh.NugaBest/helog.diwesh.NugaBest.NUGA_HealthCareActivity_Intro 
[2013-09-13 14:18:34 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] ActivityManager: Warning: Activity not started, its current task has been brought to the front
[2013-09-13 14:24:57 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] ------------------------------
[2013-09-13 14:24:57 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Android Launch!
[2013-09-13 14:24:57 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] adb is running normally.
[2013-09-13 14:24:57 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Performing helog.diwesh.NugaBest.NUGA_HealthCareActivity_Intro activity launch
[2013-09-13 14:24:57 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Failed to find an AVD compatible with target 'Google APIs'.
[2013-09-13 14:24:59 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Still no compatible AVDs with target 'Google APIs': Aborting launch.
[2013-09-13 14:24:59 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Performing helog.diwesh.NugaBest.NUGA_HealthCareActivity_Intro activity launch
[2013-09-13 14:25:01 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Launching a new emulator with Virtual Device 'Testing'
[2013-09-13 14:25:01 - Emulator] emulator: warning: opening audio output failed
[2013-09-13 14:25:01 - Emulator] 
[2013-09-13 14:25:02 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] New emulator found: emulator-5554
[2013-09-13 14:25:02 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Waiting for HOME ('android.process.acore') to be launched...
[2013-09-13 14:25:35 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] HOME is up on device 'emulator-5554'
[2013-09-13 14:25:35 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Uploading NUGA_HealthCare_bluetooth_ver4_PID_verICS.apk onto device 'emulator-5554'
[2013-09-13 14:25:47 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Installing NUGA_HealthCare_bluetooth_ver4_PID_verICS.apk...
[2013-09-13 14:26:26 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER
[2013-09-13 14:26:26 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Please check logcat output for more details.
[2013-09-13 14:26:26 - NUGA_HealthCare_bluetooth_ver4_PID_verICS] Launch canceled!

【问题讨论】:

请发布您的 logcat 错误而不是控制台日志。 我在 logCat 上没有看到堆栈跟踪,你确定你没有过滤掉错误吗?新的 Intent 很可能会使应用程序崩溃,有任何代码吗? Intent intent5=new Intent(NUGA_MainMenuActivity.this,NotesList.class);不在名单上? Hi Ansh Sharma 这不是 logcat。在 eclipse 中转到窗口->显示视图->其他->Logcat 以获取 locgat。 它是一个“控制台”日志! 'Logcat' 日志在哪里?....当您收到此错误时,只需打开 Logcat 选项卡并将该跟踪粘贴到此处 您的应用未安装。您在安装过程中收到错误 Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER 【参考方案1】:

不确定,但可能是因为您在 onClickListener 中声明了 Animation anim=null; 并且也在类的顶部。

只需从 clickListener 中删除您的声明即可。

   Button.OnClickListener mClickListener = new View.OnClickListener() 
             Animation anim = null; //Remove this line.

【讨论】:

以上是关于按钮操作使应用程序崩溃[重复]的主要内容,如果未能解决你的问题,请参考以下文章

激活 iPhone 相机操作会使我的应用程序崩溃 [重复]

拍照使应用程序崩溃[重复]

按钮不会重定向到活动,而是使应用程序崩溃

Logcat 错误描述:按钮启动使应用程序崩溃

第二次按下“恢复购买”按钮使应用程序崩溃

按钮单击使整个应用程序崩溃