添加图片后,Android应用程序无法启动

时间:2014-05-02 07:29:11

标签: java android debugging

我遇到的应用程序无法从Android虚拟设备启动。我使用的是4.4.2版本。我从res文件夹中放入drawable-mdpi文件夹的所有图像。调试错误如下所示..

Thread [<1> main] (Suspended (exception RuntimeException))  
<VM does not provide monitor information>   
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2195    
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2245 
ActivityThread.access$800(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 135    
ActivityThread$H.handleMessage(Message) line: 1196  
ActivityThread$H(Handler).dispatchMessage(Message) line: 102    
Looper.loop() line: 136 
ActivityThread.main(String[]) line: 5017    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 515  
ZygoteInit$MethodAndArgsCaller.run() line: 779  
ZygoteInit.main(String[]) line: 595 
NativeStart.main(String[]) line: not available [native method]  

MainActivity.java

import android.graphics.drawable.AnimationDrawable;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

private CrystalBall mCrystalBall = new CrystalBall();
private TextView mAnswerLabel;
private Button mGetAnswerButton;
private ImageView mCrystalBallImage;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Declare our View variables
    //Assign them the Views from layout files
    mAnswerLabel = (TextView) findViewById(R.id.textView1);
    mGetAnswerButton = (Button) findViewById(R.id.button1);

    mGetAnswerButton.setOnClickListener(new View.OnClickListener(){

        public void onClick(View arg0) {
            String answer = mCrystalBall.getAnswer();

            //Update the label with our dynamic answer
            mAnswerLabel.setText(answer);

            animateCrystalBall();
            animateAnswer();
            playSound();
        }

    });
}

private void animateCrystalBall() {
    mCrystalBallImage = (ImageView) findViewById(R.id.imageView1);
    mCrystalBallImage.setImageResource(R.drawable.ball_animation);
    AnimationDrawable ballAnimation = (AnimationDrawable) mCrystalBallImage.getDrawable();

    ballAnimation.start();
}

private void animateAnswer() {
    AlphaAnimation fadeInAnimation = new AlphaAnimation(0, 1);
    fadeInAnimation.setDuration(1500);
    fadeInAnimation.setFillAfter(true);

    mAnswerLabel.setAnimation(fadeInAnimation);
}

private void playSound() {
    MediaPlayer player = MediaPlayer.create(this, R.raw.crystal_ball);
    player.start();

    player.setOnCompletionListener(new OnCompletionListener() {


        public void onCompletion(MediaPlayer mp) {
            mp.release();
        }
    });




}

2 个答案:

答案 0 :(得分:1)

我认为AVD中的问题。尝试在真正的智能手机上重新创建虚拟设备或调试。一旦我在AVD上遇到麻烦了。但是当我尝试在真正的智能手机上进行调试时,所有错误都消失了。

答案 1 :(得分:0)

使用genymotion android vm。它使AVD站立,甚至比真实设备更快。

http://www.genymotion.com