Android Studio 2.3.3仿真应用程序中的错误消息(Nexus 5x API 23)

时间:2017-07-05 22:25:47

标签: android android-studio

我在Android Studio中创建了一个动画应用。当我模拟它时,IDE不会显示任何错误消息。但是,当我单击程序中的按钮时,它会显示一条消息: “不幸的是应用程序停止了”。 请帮我找错。以下是相关的代码块:

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends Activity {

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

        final Animation animTranslate = AnimationUtils.loadAnimation(this,R.anim.anim_translate);
        final ImageView imgTranslate = (ImageView) findViewById(R.id.imgTranslate);
        Button bounceBallButton = (Button) findViewById(R.id.bounceBallButton);
        bounceBallButton.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v)
            {
                //v.startAnimation(animTranslate);
                imgTranslate.startAnimation(animTranslate);
            }
        });

    }


}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ anim_translate.xml

<?xml version="1.0" encoding="utf-8"?>
<translate
    android:fromXDelta="0"
    android:toXDelta="1000"
    android:fromYDelta="0"
    android:toYDelta="1500"
    android:duration="500"
    android:repeatCount="infinite"
    android:repeatMode="reverse"
    xmlns:android="http://schemas.android.com/apk/res/android">
</translate>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical">

    <Button
        android:id="@+id/bounceBallButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/bounce_ball"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
    <ImageView
        android:id="@+id/imageTranslate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:src="@drawable/ball_shape"
        tools:layout_editor_absoluteX="16dp"
        tools:layout_editor_absoluteY="46dp" />
    </RelativeLayout>

我使用Debug运行应用程序后添加了LogCat windowa的内容:

07-05 21:14:25.167 2433-2433/? I/art: Not late-enabling -Xcheck:jni (already on)
07-05 21:14:25.181 2433-2438/? I/art: Debugger is no longer active
07-05 21:14:25.214 2433-2433/? W/ActivityThread: Application com.example.easypc.myballanimation is waiting for the debugger on port 8100...
07-05 21:14:25.216 2433-2433/? I/System.out: Sending WAIT chunk
07-05 21:14:26.412 2433-2438/com.example.easypc.myballanimation I/art: Debugger is active
07-05 21:14:26.421 2433-2433/com.example.easypc.myballanimation I/System.out: Debugger has connected
07-05 21:14:26.422 2433-2433/com.example.easypc.myballanimation I/System.out: waiting for debugger to settle...
07-05 21:14:26.622 2433-2433/com.example.easypc.myballanimation I/System.out: waiting for debugger to settle...
07-05 21:14:26.823 2433-2433/com.example.easypc.myballanimation I/System.out: waiting for debugger to settle...
07-05 21:14:27.024 2433-2433/com.example.easypc.myballanimation I/System.out: waiting for debugger to settle...
07-05 21:14:27.225 2433-2433/com.example.easypc.myballanimation I/System.out: waiting for debugger to settle...
07-05 21:14:27.426 2433-2433/com.example.easypc.myballanimation I/System.out: waiting for debugger to settle...
07-05 21:14:27.627 2433-2433/com.example.easypc.myballanimation I/System.out: waiting for debugger to settle...
07-05 21:14:27.828 2433-2433/com.example.easypc.myballanimation I/System.out: debugger has settled (1322)
07-05 21:14:27.833 2433-2433/com.example.easypc.myballanimation W/System: ClassLoader referenced unknown path: /data/app/com.example.easypc.myballanimation-1/lib/x86_64
07-05 21:14:27.863 2433-2518/com.example.easypc.myballanimation D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

                                                                                  [ 07-05 21:14:27.866  2433: 2433 D/         ]
                                                                                  HostConnection::get() New Host Connection established 0x7f81376e1080, tid 2433


                                                                                  [ 07-05 21:14:27.867  2433: 2433 W/         ]
                                                                                  Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 

                                                                                  [ 07-05 21:14:27.897  2433: 2518 D/         ]
                                                                                  HostConnection::get() New Host Connection established 0x7f813b051360, tid 2518


                                                                                  [ 07-05 21:14:27.898  2433: 2518 W/         ]
                                                                                  Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 
07-05 21:14:27.900 2433-2518/com.example.easypc.myballanimation I/OpenGLRenderer: Initialized EGL, version 1.4
07-05 21:14:27.900 2433-2518/com.example.easypc.myballanimation W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
07-05 21:14:27.908 2433-2518/com.example.easypc.myballanimation D/EGL_emulation: eglCreateContext: 0x7f813b061820: maj 2 min 0 rcv 2
07-05 21:14:27.912 2433-2518/com.example.easypc.myballanimation D/EGL_emulation: eglMakeCurrent: 0x7f813b061820: ver 2 0 (tinfo 0x7f813b042860)
07-05 21:14:27.938 2433-2518/com.example.easypc.myballanimation D/EGL_emulation: eglMakeCurrent: 0x7f813b061820: ver 2 0 (tinfo 0x7f813b042860)

0 个答案:

没有答案