-1

Whenever I click on the button(created by me), the emulator abruptly closes. Also, the button doesn't look like one on the emulator. Following is the screenshot. Please help!

enter image description here

The code is below:

package com.example.demoap;

import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    public void clickFunction(View view) 
    {
        Log.i("Info", "Congratulations, button pressed!");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • 1
    Switch to the logcat window and find the exception logs, then you'll find which lines of code caused the crash – ssynhtn Jul 25 '19 at 16:02

1 Answers1

4

Please kill and start adb server from console or terminal using following commands:

adb kill-server 
adb start-server

If it does not help try to restart your computer.

If you are getting

adb command not found

error then you have to go in platform-tools directory in Android SDK.

Also make sure you've added the 'clickFunction' in the 'OnClick' for the button.

Navidk
  • 612
  • 6
  • 14