开发者

Android: ZygoteInit$methodandargscaller.run() source not found

When i run the app it crashes with a "ZygoteInit$methodandargscaller.run() source not found" error and a few other "source not found". It also says something about a nullpointerexcep开发者_开发知识库tion It crashes one the line: tap[0] = (int) (System.nanoTime() / 1000000 - tapstart);

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);
            }
        }
    });
}
}


You have not created your tap[] array. You have declared it, but you need to create it using tap = new int[9] before you can access it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜