Soru & Cevap

Run hatası?

22.12.2015 - 02:06

android studio kullanıyorum..kodlarda bir sorun yok ama "run" deyip emulator uzerinden uygulamayı kullandığımızda android monitor de bu hatayı veriyor.. neden? bir yardımcı olursanız sevinirim..

 

12-22 11:56:50.576 1233-1233/com.example.nasip.bir W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa62f9288)
12-22 11:56:50.576 1233-1233/com.example.nasip.bir E/AndroidRuntime: FATAL EXCEPTION: main
                                                                     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nasip.bir/com.example.nasip.bir.Soru1}: java.lang.NullPointerException
                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                                         at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                         at android.os.Looper.loop(Looper.java:137)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                         at java.lang.reflect.Method.invokeNative(Native Method)
                                                                         at java.lang.reflect.Method.invoke(Method.java:511)
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                         at dalvik.system.NativeStart.main(Native Method)
                                                                      Caused by: java.lang.NullPointerException
                                                                         at com.example.nasip.bir.Soru1.onCreate(Soru1.java:47)
                                                                         at android.app.Activity.performCreate(Activity.java:5008)
                                                                         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                                         at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                         at android.os.Looper.loop(Looper.java:137)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                         at java.lang.reflect.Method.invokeNative(Native Method)
                                                                         at java.lang.reflect.Method.invoke(Method.java:511)
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                         at dalvik.system.NativeStart.main(Native Method)
12-22 11:56:54.440 1233-1233/? I/Process: Sending signal. PID: 1233 SIG: 9

 

16 Görüntülenme

7 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-66816-1453912116.jpg
kemalcetincs
24.12.2015 - 01:24

gitmek istediğin sayfalar fragment mi?

 

 

Profile picture for user hayatigndz
hayatigndz
22.12.2015 - 07:37
12-22 17:35:48.844 990-994/com.example.nasip.bir D/dalvikvm: GC_CONCURRENT freed <1K, 12% free 29133K/32775K, paused 10ms+0ms, total 24ms
12-22 17:35:48.884 990-990/com.example.nasip.bir D/AndroidRuntime: Shutting down VM
12-22 17:35:48.884 990-990/com.example.nasip.bir W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa62d6288)
12-22 17:35:48.884 990-990/com.example.nasip.bir E/AndroidRuntime: FATAL EXCEPTION: main
                                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nasip.bir/com.example.nasip.bir.Soru1}: java.lang.NullPointerException
                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                                       at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                       at android.os.Looper.loop(Looper.java:137)
                                                                       at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                       at java.lang.reflect.Method.invokeNative(Native Method)
                                                                       at java.lang.reflect.Method.invoke(Method.java:511)
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                       at dalvik.system.NativeStart.main(Native Method)
                                                                    Caused by: java.lang.NullPointerException
                                                                       at com.example.nasip.bir.Soru1.onCreate(Soru1.java:47)
                                                                       at android.app.Activity.performCreate(Activity.java:5008)
                                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
                                                                       at android.app.ActivityThread.access$600(ActivityThread.java:130) 
                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
                                                                       at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                       at android.os.Looper.loop(Looper.java:137) 
                                                                       at android.app.ActivityThread.main(ActivityThread.java:4745) 
                                                                       at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                       at java.lang.reflect.Method.invoke(Method.java:511) 
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                                                                       at dalvik.system.NativeStart.main(Native Method) 
12-22 17:35:50.400 990-990/? I/Process: Sending signal. PID: 990 SIG: 9

 

Profile picture for user hayatigndz
hayatigndz
22.12.2015 - 07:34
package com.example.nasip.bir;

import android.content.Intent;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;

public class Soru1 extends AppCompatActivity {

    ImageView iv2;
    ImageButton ib;
    Button button1, button2, button3, button4;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_soru1);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        iv2 = (ImageView)findViewById(R.id.imageView2);
        ib = (ImageButton)findViewById(R.id.imageButton);
        button1 = (Button)findViewById(R.id.button);
        button2 = (Button)findViewById(R.id.button2);
        button3 = (Button)findViewById(R.id.button3);
        button4 = (Button)findViewById(R.id.button4);

        final MediaPlayer mp = MediaPlayer.create(this, R.raw.sorubasi);
        mp.start();

        ib.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Soru1.this, joker1.class);
                startActivity(intent);
            }
        });

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button1.setBackgroundColor(Color.RED);
                Toast.makeText(getApplicationContext(), "Maalesef Yanlış Cevap!! O TL Kazandınız :(", Toast.LENGTH_LONG).show();
                Intent i = new Intent(Soru1.this, yanliscevap1.class);
                startActivity(i);
                finish();



            }
        });

        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button2.setBackgroundColor(Color.RED);
                Toast.makeText(getApplicationContext(), "Maalesef Yanlış Cevap!! O TL Kazandınız :(", Toast.LENGTH_LONG).show();
                Intent i = new Intent(Soru1.this, yanliscevap1.class);
                startActivity(i);
                finish();


            }
        });

        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button3.setBackgroundColor(Color.GREEN);
                Toast.makeText(getApplicationContext(), "Tebrikler.. Doğru Cevap :)", Toast.LENGTH_LONG).show();
                Intent i = new Intent(Soru1.this, dogrucevap1.class);
                startActivity(i);
                finish();


            }
        });
        button4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button4.setBackgroundColor(Color.RED);
                Toast.makeText(getApplicationContext(), "Maalesef Yanlış Cevap!! O TL Kazandınız :(", Toast.LENGTH_LONG).show();
                Intent i = new Intent(Soru1.this, yanliscevap1.class);
                startActivity(i);
                finish();



            }
        });

    }

}

 

Hayati
22.12.2015 - 07:40
emulatore girip uygulamayı çalıştırınca aşağıdaki hatalar zincirini veriyo.. halbuki 2 tane java dosyası açıp birbirine geçiş yapabiliyorum aynı kodlarla.. soru1 içindeki diğer intent geçişleri mi etkiliyo olabilir?? manifestte de tanımlı.. çözemedim :(
Umut ONUR
24.12.2015 - 02:12
Kodlarda bi sorun gözükmüyor.. dogrucevap1'i seçtiğinde de aynı benzer bi hata alıyor musun?
picture-28812-1452251417.jpg
umutonur
22.12.2015 - 02:48

Öncelikle kodlarını "Kod Parçacığı Ekle" yaparak ekler misin?

/sites/default/files/cevaplar/dosya/2020/file-kodparcacigiekle.png
Profile picture for user hayatigndz
hayatigndz
22.12.2015 - 02:27

intent geçişlerinde mi sıkıntı var acaba.. uygulamayı emulatorde çalıştırdığımızda en üstteki hata kodlarını veriyo..

Profile picture for user hayatigndz
hayatigndz
22.12.2015 - 02:24

Soru1.java daki kodlar


package com.example.nasip.bir; import android.content.Intent; import android.graphics.Color; import android.media.MediaPlayer; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.Toast; public class Soru1 extends AppCompatActivity { ImageView iv2; ImageButton ib; Button button1, button2, button3, button4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_soru1); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); iv2 = (ImageView)findViewById(R.id.imageView2); ib = (ImageButton)findViewById(R.id.imageButton); button1 = (Button)findViewById(R.id.button); button2 = (Button)findViewById(R.id.button2); button3 = (Button)findViewById(R.id.button3); button4 = (Button)findViewById(R.id.button4); final MediaPlayer mp = MediaPlayer.create(this, R.raw.sorubasi); mp.start(); ib.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Soru1.this, joker1.class); startActivity(intent); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { button1.setBackgroundColor(Color.RED); Toast.makeText(getApplicationContext(), "Maalesef Yanlış Cevap!! O TL Kazandınız :(", Toast.LENGTH_LONG).show(); Intent i = new Intent(Soru1.this, yanliscevap1.class); startActivity(i); finish(); } }); button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { button2.setBackgroundColor(Color.RED); Toast.makeText(getApplicationContext(), "Maalesef Yanlış Cevap!! O TL Kazandınız :(", Toast.LENGTH_LONG).show(); Intent i = new Intent(Soru1.this, yanliscevap1.class); startActivity(i); finish(); } }); button3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { button3.setBackgroundColor(Color.GREEN); Toast.makeText(getApplicationContext(), "Tebrikler.. Doğru Cevap :)", Toast.LENGTH_LONG).show(); Intent i = new Intent(Soru1.this, dogrucevap1.class); startActivity(i); finish(); } }); button4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { button4.setBackgroundColor(Color.RED); Toast.makeText(getApplicationContext(), "Maalesef Yanlış Cevap!! O TL Kazandınız :(", Toast.LENGTH_LONG).show(); Intent i = new Intent(Soru1.this, yanliscevap1.class); startActivity(i); finish(); } }); } }
 

picture-28812-1452251417.jpg
umutonur
22.12.2015 - 02:11

Soru1.java dosyasında ki kodlarını bizimle paylaşırsan yardımcı olmaya çalışırız.