GUJ Discussões   :   últimos tópicos   |   categorias   |   GUJ Respostas

Erro: The application (nome da app)(process(nome do pacote)) has stopped unexpectedly


#1

Olá a todos,

ao tentar executar meu projeto no emulador do Android, apareceu esse erro:

The application (nome da app)(process(nome do pacote)) has stopped unexpectedly. Please try again.

Coloquei o projeto em anexo.

Abaixo, o que apareceu no logcat até antes de eu clicar "force close":

06-30 18:28:27.136: DEBUG/AndroidRuntime(467): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
06-30 18:28:27.136: DEBUG/AndroidRuntime(467): CheckJNI is ON
06-30 18:28:29.065: DEBUG/AndroidRuntime(467): Calling main entry com.android.commands.pm.Pm
06-30 18:28:29.155: DEBUG/AndroidRuntime(467): Shutting down VM
06-30 18:28:29.185: DEBUG/dalvikvm(467): GC_CONCURRENT freed 101K, 71% free 297K/1024K, external 0K/0K, paused 3ms+2ms
06-30 18:28:29.185: INFO/AndroidRuntime(467): NOTE: attach of thread 'Binder Thread #3' failed
06-30 18:28:29.195: DEBUG/jdwp(467): Got wake-up signal, bailing out of select
06-30 18:28:29.195: DEBUG/dalvikvm(467): Debugger has detached; object registry had 1 entries
06-30 18:28:30.235: DEBUG/AndroidRuntime(477): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
06-30 18:28:30.235: DEBUG/AndroidRuntime(477): CheckJNI is ON
06-30 18:28:31.785: DEBUG/AndroidRuntime(477): Calling main entry com.android.commands.am.Am
06-30 18:28:31.885: INFO/ActivityManager(70): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=br.com.learning.aula5/.Tela1 } from pid 477
06-30 18:28:32.186: DEBUG/AndroidRuntime(477): Shutting down VM
06-30 18:28:32.266: INFO/AndroidRuntime(477): NOTE: attach of thread 'Binder Thread #3' failed
06-30 18:28:32.375: DEBUG/dalvikvm(477): GC_CONCURRENT freed 102K, 69% free 320K/1024K, external 0K/0K, paused 3ms+65ms
06-30 18:28:32.415: DEBUG/jdwp(477): Got wake-up signal, bailing out of select
06-30 18:28:32.425: DEBUG/dalvikvm(477): Debugger has detached; object registry had 1 entries
06-30 18:28:32.545: INFO/ActivityManager(70): Start proc br.com.learning.aula5 for activity br.com.learning.aula5/.Tela1: pid=486 uid=10036 gids={}
06-30 18:28:34.285: DEBUG/AndroidRuntime(486): Shutting down VM
06-30 18:28:34.285: WARN/dalvikvm(486): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 18:28:34.355: ERROR/AndroidRuntime(486): FATAL EXCEPTION: main
06-30 18:28:34.355: ERROR/AndroidRuntime(486): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{br.com.learning.aula5/br.com.learning.aula5.Tela1}: java.lang.NullPointerException
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.os.Looper.loop(Looper.java:123)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at java.lang.reflect.Method.invokeNative(Native Method)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at java.lang.reflect.Method.invoke(Method.java:507)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at dalvik.system.NativeStart.main(Native Method)
06-30 18:28:34.355: ERROR/AndroidRuntime(486): Caused by: java.lang.NullPointerException
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.Activity.findViewById(Activity.java:1647)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at br.com.learning.aula5.Tela1.<init>(Tela1.java:15)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at java.lang.Class.newInstanceImpl(Native Method)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at java.lang.Class.newInstance(Class.java:1409)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
06-30 18:28:34.355: ERROR/AndroidRuntime(486):     ... 11 more
06-30 18:28:34.406: WARN/ActivityManager(70):   Force finishing activity br.com.learning.aula5/.Tela1
06-30 18:28:34.985: WARN/ActivityManager(70): Activity pause timeout for HistoryRecord{406a1660 br.com.learning.aula5/.Tela1}
06-30 18:28:46.677: WARN/ActivityManager(70): Activity destroy timeout for HistoryRecord{406a1660 br.com.learning.aula5/.Tela1}

#2

Olá,

olhei o teu projeto e vi que o erro está aqui:

Classe Tela1

EditText cxNome = (EditText)findViewById(R.id.inputNomeEditText);
	EditText cxEmail = (EditText)findViewById(R.id.inputEmailEditText);
	Button btnProximo1 = (Button)findViewById(R.id.tela01ProximoButton);
	TextView status = (TextView)findViewById(R.id.statusTela1TextView);
    public void onCreate(Bundle savedInstanceState) {       
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnProximo1.setOnClickListener(this);
        Log.v("curso", "Tela1 - executando método onCreate");
    }

tenta assim:

        EditText cxNome ;
	EditText cxEmail ;
	Button btnProximo1;
	TextView status ;
    public void onCreate(Bundle savedInstanceState) {       
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        cxNome = (EditText)findViewById(R.id.inputNomeEditText); 
        cxEmail = (EditText)findViewById(R.id.inputEmailEditText);
        btnProximo1 = (Button)findViewById(R.id.tela01ProximoButton);
        status = (TextView)findViewById(R.id.statusTela1TextView);
        btnProximo1.setOnClickListener(this);
        Log.v("curso", "Tela1 - executando método onCreate");
    }

Obs¹:
o erro está dando porque o findViewById() busca no layout da Activy e voce está setando o layout no onCreate... então tem que usar o findViewById() depois que setar o layout da Activity.

Obs²:
Ajuste nas outras Classes também...

Abçs...


#3

Muito obrigada caio! :smiley: Problema resolvido! Vcs aqui do fórum são bons mesmo, deviam montar um curso! rs

Obrigada mais uma vez :smile:

[Resolvido]


#4