在Android studio运行模拟器时报错Emulator: qemu_ram_alloc_user_backed: call

每次启动模拟器都会报这个错误,刚接触Android开发不知道为啥,有没有大佬解答一下。

package com.example.lenovo.myapplication;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;

public class MainActivity extends AppCompatActivity {

    private int zmkuan;
    int zmGao;
    //小球的变量
    float qiu_size = 16;
    float qiu_sudu =3;
    float qiu_shang = 90;
    float qiuX;
    float qiuY;
    //柱子的变量
    float zhu_gao ;
    float zhu_gao_2;
    float zhu_kaun = 80;
    float zhu_kaun_2 = 80;
    float zhuX;
    float zhuY;
    float zhuX_2;
    float zhuY_2;
    float zhu_sudu;

    int num = 0;//小球通过柱子数

    boolean jieshu = false;//盘孤单小球是否结束
    MyGameView myGameView;//为了能在全局访问到这个变量
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置为全屏,固定写法
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //使游戏横屏,修改配置文件AndroidMainifest.xml: <activity android:name=".MainActivity" android:screenOrientation="landscape">
        //获取游戏视图
        MyGameView myGameView = new MyGameView(this);
        setContentView(myGameView);
        //获取窗口的一个管理器,固定写法
        WindowManager windowManager = getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);
        //获取屏幕的宽和高
        zmkuan = metrics.widthPixels;
        zmGao = metrics.heightPixels;
        play();
    }
    public void play(){
        jieshu = false;
        //设置两根柱子的初始位置
        zhuX = zmkuan - zhu_kaun;
        zhuY = 0;
        zhuX_2 = zmkuan - zhu_kaun_2;
        zhuY_2 = zmGao;
        zhu_gao = zmGao/2 - 200;
        zhu_gao_2 = zmGao -zhu_gao -200;
        num = 0;
        zhu_sudu = 5;

        qiu_sudu = 3.5f;
        qiu_shang = 90;
        qiuX = 50;
        qiuY = zmGao/2;
        handler.sendEmptyMessage(0x123);
    }

    Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 0x123){
                myGameView.invalidate();
            }
        }
    };
    class MyGameView extends View {
        Paint paint = new Paint();
        public MyGameView(Context context) {
            super(context);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            paint.setStyle(Paint.Style.FILL);
            paint.setAntiAlias(true);//设置抗锯齿
            if (jieshu){
                //执行游戏结束后的效果
            }else {
                paint.setColor(Color.RED);
                paint.setTextSize(80);
                canvas.drawText(num+"",zmkuan/2-10,80,paint);
                canvas.drawCircle(qiuX, qiuY, qiu_size, paint);
                //绘制上柱子
                paint.setColor(Color.rgb(80,80,200));
                canvas.drawRect(zhuX,zhuY,zhuX+zhu_kaun,zhuY+zhu_gao,paint);
                //绘制下柱子
                canvas.drawRect(zhuX_2,zhuY_2,zhuX_2+zhu_kaun_2,zhuY_2+zhu_gao_2,paint);
            }
        }
    }
}


event log报错信息:图片说明

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐