Android:ZygoteInit$methodandargscaller.run()未找到源代码

Android:ZygoteInit$methodandargscaller.run()未找到源代码,android,debugging,nullpointerexception,Android,Debugging,Nullpointerexception,当我运行应用程序时,它会崩溃,出现“ZygoteInit$methodandargscaller.run()source not found”错误和其他一些“source not found”。它还表示了有关nullpointerexception的内容 它使一行崩溃:点击[0]=(int)(System.nanoTime()/1000000-tapstart) package com.metronome; 导入android.app.Activity; 导入android.app.Dialog

当我运行应用程序时,它会崩溃,出现“ZygoteInit$methodandargscaller.run()source not found”错误和其他一些“source not found”。它还表示了有关nullpointerexception的内容 它使一行崩溃:点击[0]=(int)(System.nanoTime()/1000000-tapstart)

package com.metronome;
导入android.app.Activity;
导入android.app.Dialog;
导入android.content.Context;
导入android.media.MediaPlayer;
导入android.os.Bundle;
导入android.os.Handler;
导入android.os.Message;
导入android.text.Editable;
导入android.view.view;
导入android.widget.Button;
导入android.widget.CompoundButton;
导入android.widget.CompoundButton.OnCheckedChangeListener;
导入android.widget.EditText;
导入android.widget.FrameLayout;
导入android.widget.SeekBar;
导入android.widget.SeekBar.onseekbarchaneglistener;
导入android.widget.TextView;
导入android.widget.Toast;
导入android.widget.ToggleButton;
公共类节拍器活动扩展了活动{
公共整数bpm=150;
专用长tapstart=0;
私人int tap[];
私有int cnt=0;
私有int gnstap=0;
私人整数和;
框架布局主机;
SeekBar杆;
文本视图bpmText;
切换按钮切换;
MediaPlayer mp;
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainFrame=(FrameLayout)findViewById(R.id.FrameLayout);
Bar=(SeekBar)findViewById(R.id.seekBar1);
bpmText=(TextView)findViewById(R.id.textView1);
toggle=(ToggleButton)findViewById(R.id.toggleButton1);
bpmText.setText(bpm+“bpm”);
//听众
mainFrame.setOnClickListener(新视图.OnClickListener(){
公共void onClick(视图v){
如果(点击开始!=0){
点击[0]=(int)(System.nanoTime()/1000000-tapstart);
tapstart=(System.nanoTime()/1000000);
if(cnt<9){
cnt++;
}否则{
cnt=0;
}
总和=0;
对于(int i=0;i
您尚未创建
点击[]
数组。您已经声明了它,但需要使用
tap=newint[9]
创建它,然后才能访问它

package com.metronome;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MetronomeActivity extends Activity {

public int bpm = 150;
private long tapstart = 0;
private int tap[];
private int cnt = 0;
private int gnstap = 0;
private int sum;

FrameLayout mainFrame;
SeekBar Bar;
TextView bpmText;
ToggleButton toggle;
MediaPlayer mp;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mainFrame = (FrameLayout) findViewById(R.id.FrameLayout);
    Bar = (SeekBar) findViewById(R.id.seekBar1);
    bpmText = (TextView) findViewById(R.id.textView1);
    toggle = (ToggleButton) findViewById(R.id.toggleButton1);

    bpmText.setText(bpm + " BPM");

    // listeners

    mainFrame.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (tapstart != 0) {

                tap[0] = (int) (System.nanoTime() / 1000000 - tapstart);
                tapstart = (System.nanoTime() / 1000000);
                if (cnt < 9) {
                    cnt++;
                } else {
                    cnt = 0;
                }
                sum = 0;
                for(int i=0; i < tap.length ; i++)
                    sum = sum + tap[i];

                gnstap = sum/tap.length;
                bpm = 60000/gnstap;
                bpmText.setText(bpm + " BPM");
            } 
            else {
                tapstart = (System.nanoTime() / 1000000);
            }
        }
    });
}
}