Why does my app keep crashing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why does my app keep crashing?

I am creating an app that uses an age restriction when started and this is what I am working on first, but when I run my appit crashes immediately with no prompt and with no 'this app has stopped', notification. I am using android studio. There is no problem with android studio because I have run different sets oof code and projects and they turn out fine. It crashes on both the emulator and adb device. I have attached the code. Please ask for anything else and help as soon as possible import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import java.util.Scanner; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Scanner s1 = new Scanner(System.in); System.out.println(s1.nextInt()); int age = s1.nextInt(); if (age < 0) { System.out.

10th Dec 2018, 3:45 PM
EthanPlusPlus
EthanPlusPlus - avatar
3 Answers
0
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import java.util.Scanner; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Scanner s1 = new Scanner(System.in); System.out.println(s1.nextInt()); int age = s1.nextInt(); if (age < 0) { System.out.println("Really"); } else if (age < 16) { System.out.println("Sorry, you are too young for this game. Please exit!"); } else if (age < 100) { System.out.println("Welcome!"); } else { System.out.println("Really?"); } } }
10th Dec 2018, 3:45 PM
EthanPlusPlus
EthanPlusPlus - avatar
0
This is the entire code👆
10th Dec 2018, 3:46 PM
EthanPlusPlus
EthanPlusPlus - avatar
0
#Code
12th Dec 2018, 7:38 AM
EthanPlusPlus
EthanPlusPlus - avatar