.apk不会安装在AVD上。清单不更新?

时间:2015-01-22 15:12:42

标签: java android eclipse manifest avd

因此,我已经将这个简单的应用程序构建为我参与的自我学习机器人课程的一部分。它工作正常,直到我对Java文件进行了一些更改,然后尝试重新安装并再次启动。从我所做的研究中我认为它与清单有关,但我不确定是什么问题。如果你需要看到别的东西就问。我真的很难过。它一直在工作,直到我添加了switch语句。这是一个if else群集,我被告知要尝试使用switch statement。它似乎在日食中检查,但我无法弄清楚这一点。这是logcat输出。

  

01-22 07:43:12.106:E / libprocessgroup(1717):制作和播放失败   / acct / uid_10054:只读文件系统01-22 07:43:12.106:   W / Zygote(1717):createProcessGroup失败,内核丢失   CONFIG_CGROUP_CPUACCT? 01-22 07:43:12.107:我/艺术(1717):不是   迟到-Xcheck:jni(已经开启)01-22 07:43:12.192:   D / AndroidRuntime(1717):关闭VM 01-22 07:43:12.192:   D / AndroidRuntime(1717):---------崩溃01-22开始   07:43:12.193:E / AndroidRuntime(1717):致命异常:主01-22   07:43:12.193:E / AndroidRuntime(1717):流程:   com.codeherenow.trafficlights,PID:1717 01-22 07:43:12.193:   E / AndroidRuntime(1717):java.lang.RuntimeException:无法   实例化活动   ComponentInfo {com.codeherenow.trafficlights / com.codeherenow.trafficlights.TrafficLightsActivity}:   java.lang.InstantiationException:class   com.codeherenow.trafficlights.TrafficLightsActivity不可以   实例化01-22 07:43:12.193:E / AndroidRuntime(1717):at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)   01-22 07:43:12.193:E / AndroidRuntime(1717):at   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)   01-22 07:43:12.193:E / AndroidRuntime(1717):at   android.app.ActivityThread.access $ 800(ActivityThread.java:144)01-22   07:43:12.193:E / AndroidRuntime(1717):at   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1278)   01-22 07:43:12.193:E / AndroidRuntime(1717):at   android.os.Handler.dispatchMessage(Handler.java:102)01-22   07:43:12.193:E / AndroidRuntime(1717):at   android.os.Looper.loop(Looper.java:135)01-22 07:43:12.193:   E / AndroidRuntime(1717):at   android.app.ActivityThread.main(ActivityThread.java:5221)01-22   07:43:12.193:E / AndroidRuntime(1717):at   java.lang.reflect.Method.invoke(Native Method)01-22 07:43:12.193:   E / AndroidRuntime(1717):at   java.lang.reflect.Method.invoke(Method.java:372)01-22 07:43:12.193:   E / AndroidRuntime(1717):at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:899)   01-22 07:43:12.193:E / AndroidRuntime(1717):at   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)01-22   07:43:12.193:E / AndroidRuntime(1717):引起:   java.lang.InstantiationException:class   com.codeherenow.trafficlights.TrafficLightsActivity不可以   实例化01-22 07:43:12.193:E / AndroidRuntime(1717):at   java.lang.Class.newInstance(Class.java:1553)01-22 07:43:12.193:   E / AndroidRuntime(1717):at   android.app.Instrumentation.newActivity(Instrumentation.java:1065)   01-22 07:43:12.193:E / AndroidRuntime(1717):at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)   01-22 07:43:12.193:E / AndroidRuntime(1717):... 10更多01-22   07:48:13.660:I / Process(1717):发送信号。 PID:1717 SIG:9

这是Manifest:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.codeherenow.trafficlights"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name="com.codeherenow.trafficlights.TrafficLightsActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

这是java:

package com.codeherenow.trafficlights;


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

public abstract class TrafficLightsActivity extends Activity implements OnClickListener {

        private ImageView redLight;
        private ImageView yellowLight;
        private ImageView greenLight;

        private Button redButton;
        private Button yellowButton;
        private Button greenButton;



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

        redLight=(ImageView) findViewById(R.id.red_light);
        yellowLight=(ImageView) findViewById(R.id.yellow_light);
        greenLight=(ImageView) findViewById(R.id.green_light);


        redButton=(Button) findViewById(R.id.Red_Button);
        yellowButton=(Button) findViewById(R.id.Yellow_Button);
        greenButton=(Button) findViewById(R.id.Green_Button);


        redButton.setOnClickListener(this);
        yellowButton.setOnClickListener(this);
        greenButton.setOnClickListener(this);
        redLight.setOnClickListener(this);
        yellowLight.setOnClickListener(this);
        greenLight.setOnClickListener(this);


    }



    public void onClick (View v) {
        int v2=v.getId();
         turnOffLight();

        // TODO Auto-generated method stub
        switch(v2){
        case R.id.Red_Button:case R.id.red_light:
            turnOnRedLight();
            break;

        case R.id.Yellow_Button: case R.id.yellow_light:
            turnOnYellowLight();
            break;

        case R.id.Green_Button: case R.id.green_light:
            turnOnGreenLight();
            break;

            default:
            break;


        }

    }



    private void turnOffLight() {
        // TODO Auto-generated method stub
        redLight.setImageResource(R.drawable.light_off);
        greenLight.setImageResource(R.drawable.light_off);
        yellowLight.setImageResource(R.drawable.light_off);
    }





    private void turnOnGreenLight() {
        // TODO Auto-generated method stub
        greenLight.setImageResource(R.drawable.green_on);
    }



    private void turnOnYellowLight() {
        // TODO Auto-generated method stub
        yellowLight.setImageResource(R.drawable.yellow_on);
    }



    private void turnOnRedLight() {
        // TODO Auto-generated method stub
        redLight.setImageResource(R.drawable.red_on);
    }

}

1 个答案:

答案 0 :(得分:0)

public abstract class TrafficLightsActivity

,您的错误是Caused by: java.lang.InstantiationException: ..

解决方案

public class TrafficLightsActivity