마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Unfortunately, Hello has stopped. 왜이런게 뜨는거죠?

0 추천
-------------메인엑티비티.자바-------------

package org.androidtown.hello;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

public class MainActivity extends ActionBarActivity {

    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    public void onButton1Clicked(View v) {
        Toast.makeText(getApplicationContext(), "버튼이 눌렸어요.", Toast.LENGTH_LONG).show();

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.naver.com"));
        startActivity(intent);

    }

    public void onButton2Clicked(View v) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:010-1000-1000"));
        startActivity(intent);

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://org.androidtown.hello/http/host/path")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://org.androidtown.hello/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        client.disconnect();
    }
 

만졸이 (130 포인트) 님이 2015년 12월 8일 질문
만졸이님이 2015년 12월 8일 수정
에러가 났으니, 에러 로그를 올려주셔야 합니다.
에러 로그라는게 어떤건지 잘모르겠어요 완전 초짜라서.. run 여기에 있는거 복사해서 올리면 될까요??
12-08 09:03:15.387 4780-4780/? I/art: Not late-enabling -Xcheck:jni (already on)
12-08 09:03:15.961 4780-4780/? W/Zygote: Slow operation: 1135ms so far, now at Zygote.postForkCommon
12-08 09:03:15.962 4780-4780/? W/Zygote: Slow operation: 1161ms so far, now at zygoteConnection.runOnce: postForkAndSpecialize
12-08 09:03:17.581 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 189.780ms
12-08 09:03:19.533 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 163.704ms
12-08 09:03:20.462 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 74.812ms
12-08 09:03:20.563 4780-4792/org.androidtown.hello I/art: Background sticky concurrent mark sweep GC freed 3041(235KB) AllocSpace objects, 0(0B) LOS objects, 22% free, 883KB/1135KB, paused 3.469ms total 306.204ms
12-08 09:03:20.568 4780-4792/org.androidtown.hello W/art: Suspending all threads took: 5.090ms
12-08 09:03:20.579 4780-4831/org.androidtown.hello W/GooglePlayServicesUtil: Google Play services is missing.
12-08 09:03:20.899 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 27.656ms
12-08 09:03:20.952 4780-4792/org.androidtown.hello W/art: Suspending all threads took: 13.425ms
12-08 09:03:20.981 4780-4792/org.androidtown.hello I/art: Background partial concurrent mark sweep GC freed 1347(94KB) AllocSpace objects, 0(0B) LOS objects, 50% free, 991KB/2015KB, paused 25.768ms total 288.845ms
12-08 09:03:21.764 4780-4780/org.androidtown.hello D/gralloc_goldfish: Emulator without GPU emulation detected.
12-08 09:03:22.471 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 83.741ms
12-08 09:03:23.323 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 422.980ms
12-08 09:03:23.412 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 30.195ms
12-08 09:03:24.021 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 120.505ms
12-08 09:03:24.142 4780-4780/org.androidtown.hello I/Choreographer: Skipped 121 frames!  The application may be doing too much work on its main thread.
12-08 09:03:31.419 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 20.230ms
12-08 09:03:47.463 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 21.618ms
12-08 09:05:01.142 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 20.372ms
12-08 09:05:28.815 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 123.316ms
12-08 09:05:29.762 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 71.434ms
12-08 09:05:30.208 4780-4787/org.androidtown.hello W/art: Suspending all threads took: 5.185ms
12-08 09:05:30.554 4780-4780/org.androidtown.hello D/AndroidRuntime: Shutting down VM
12-08 09:05:30.571 4780-4780/org.androidtown.hello E/AndroidRuntime: FATAL EXCEPTION: main
                                                                     Process: org.androidtown.hello, PID: 4780
                                                                     java.lang.IllegalStateException: Could not find a method onButton1Cliked(View) in the activity class org.androidtown.hello.MainActivity for onClick handler on view class android.widget.Button with id 'button'
                                                                         at android.view.View$1.onClick(View.java:3994)
                                                                         at android.view.View.performClick(View.java:4756)
                                                                         at android.view.View$PerformClick.run(View.java:19749)
                                                                         at android.os.Handler.handleCallback(Handler.java:739)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                         at android.os.Looper.loop(Looper.java:135)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5221)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at java.lang.reflect.Method.invoke(Method.java:372)
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
                                                                      Caused by: java.lang.NoSuchMethodException: onButton1Cliked [class android.view.View]
                                                                         at java.lang.Class.getMethod(Class.java:664)
                                                                         at java.lang.Class.getMethod(Class.java:643)
                                                                         at android.view.View$1.onClick(View.java:3987)
                                                                         at android.view.View.performClick(View.java:4756) 
                                                                         at android.view.View$PerformClick.run(View.java:19749) 
                                                                         at android.os.Handler.handleCallback(Handler.java:739) 
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                         at android.os.Looper.loop(Looper.java:135) 
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5221) 
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
12-08 09:05:39.020 4780-4780/org.androidtown.hello I/Process: Sending signal. PID: 4780 SIG: 9

1개의 답변

+1 추천
...
Caused by: java.lang.NoSuchMethodException: onButton1Cliked
...

1. res/menu/main.xml 에서 android:onClick="onButton1Cliked" 확인
onButton1Cliked -> onButton1Clicked

2. onClick
public void onButton1Clicked(View v) {...}
public void onButton2Clicked(View v) {...}

// 이렇게 사용
public void onButton1Clicked(MenuItem item) {...}
public void onButton2Clicked(MenuItem item) {...}

// or

public boolean onOptionsItemSelected(MenuItem item) {
    switch ( item.getItemId() ) {
        case R.id.settings:
            return true;
        case ...:
            return true;
        ...
    }
    return false;
}
익명사용자 님이 2015년 12월 8일 답변
...