Android Build a Simple Android App Basic Android Programming Generating a Random Number

Mohammad Abdur Rahman
Mohammad Abdur Rahman
1,986 Points

emulator & app not working

I have tried everything and I still can't figure it out. I don't think there is problem with the code. when I run the code, its taking too much time to launch the app then showing error : 02/17 23:17:58: Launching app Error while waiting for device: The emulator process for AVD Nexus_5_API_23 was killed.

Then i tried to run on my phone, still not working PLEASE HELP!! package com.example.mac.myapplication;

import; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView;

import java.util.Random;

public class MainActivity extends AppCompatActivity { // Declare view variables private TextView mFactTextView; private Button mFactButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mFactTextView = (TextView) findViewById(; mFactButton = (Button) findViewById(;

    View.OnClickListener listener = new View.OnClickListener(){
        public void onClick(View v){
            String fact = "";
            // randomly select fact
            Random randomGenerator = new Random();
            int randomNumber = randomGenerator.nextInt(3);
            fact = randomNumber +"";
            // update the screen with dynamic fact




1 Answer

are all the files in the studio up to date have you updated them also try to clean your code and try to run again also you should try download and use another emulator like genymotion